templateLink does not exixst - azure

So I am trying to deploy this script from Github. What it should do is deploy a VM to my existing resource group. Then it should install an Integration Runtime on it and link it to my existing Data Factory. The part that is not working is installing the IR in the first place.
In the main.bicep file, there is the following parameter:
#description('The base URI where artifacts required by this template are located.')
param _artifactsLocation string = deployment().properties.templateLink.uri
The error that I am getting is, that the "templateLink" doesn't exist. I am guessing it has something to do with me deploying the script locally, however I cannot change said parameter because I don't understand what it is doing in the first place.
So how do I solve this? Thanks in advance!

you need to deploy this bicep file from github using this url: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.compute/vms-with-selfhost-integration-runtime/main.bicep
instead of cloning and deploying locally, that way it will have templateLink property will exist on the deployment

Related

How to change Azure App Services Github workflow deployment environment name

When you create an app there's no option to customize this, it's just there by default.
This matters because sometimes I don't want github actions to say that I'm deploying to "production", I want it to say I'm deploying to "development". But if I change this property manually, I'll get an error in github actions saying: Error: Deployment Failed with Error: Error: Publish profile is invalid for app-name and slot-name provided. Provide correct publish profile credentials for app. But then as soon as it's changed back the deployment works again, so I need to find a way to change this property in Azure?
Always the main slot of the webapp is called production, there is no way to change it.

Error when deploying custom template in Azure from Azure DevOps repo ("deploy to azure" button)

All,
I'm trying to use the "deploy to Azure" button, using a template stored in Azure DevOps Git repo.
I'm receiving the following error:
Error parsing template. Please ensure template is valid JSON. Invalid symbol at character position 4. (3 other errors).
I created the URL following what is described in https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-to-azure-button.
My structure is the following:
Azure DevOps organization = MyOrganization and project is myProject
Repo is myRepo, and the template file is on branch myBranch, located at myFolder/myTemplate.json.
At the end, the URL looks like
https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fdev.azure.com%2F{myOrganization}%2F{myProject}%2F_apis%2Fgit%2Frepositories%2F{myRepo}%2Fitems%3Fpath%3D%2F{myFolder}%2F{myTemplate}.json%26versionDescriptor.version%3D{myBranch}%26versionDescriptor.versionType%3Dbranch%26api-version%3D6.0
Copy/pasting this URL in a browser returns the above error...
I believe my JSON file is correct (no error) because it works fine in the following two situations:
if using the same JSON template file with Azure CLI (az deployment groupe create --template-file <myJSONtemplatefile> --parameters <myJSONparametersfile>
if copy/pasting the JSON template file in Azure portal for custom deployment at https://portal.azure.com/#create/Microsoft.Template
I don't get what is the reason of the Error parsing template...
Found!
Issue was due to the fact that the AzDO repo is private, and not public.
This was clearly stated in Microsoft documentation, but I missed it... (bolding word is mine)
If you're using Git with Azure Repos instead of a GitHub repo, you can still use the Deploy to Azure button. Make sure your repo is public. Use the Items operation to get the template.
With a public AzDO repo, everything works like a charm.

Build fails on CI pipeline

I am trying to build a CI pipeline, which is failing with an error "
Creating deployment parameters. ##[error]Check out the troubleshooting guide to see if your issue is addressed: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
[error]Error: Could not find any file matching the template file pattern
am not understanding what to be the path exactly is ? am copying the path where the Json file is (which is local)(C:\Testrepos\Templates\TestDEVOPS\dep?loy.json, is this correct? what could be the linked artifact?
I understand that you are getting the error in the task, Azure resource group deployment, right?
You have to upload your ARM templates to some place that Devops can access, not your local, normally I use a blob storage.
Then you put you ARM template urls in his box.
Your ARM templates have to be uploaded somewhere available on the internet for devops to access them. This is the key.
I hope this help you!

VSTS Build Succeeded even ARM Template was invalid

Am working on Azure Resource Manager Templates(ARM Templates) and VSTS CI&CD. With the help of ARM Templates, I want to deploy AKS (Azure kubernete Service). So before going to deploy, I need to validate my ARM Template in the CI-Build by applying a PowerShell task. But here, at the time of validating my ARM Template “It’s not stopping CI-Build even when the validation fails”. Its giving output as “Validation Completed” as shown in the below picture . Is there any solution to resolve this issue, i.e. I wanted to stop my CI-Build running if any validation fails.
Not sure how does your powershell script look like. But according to the screenshot, the powershell script is executed successfully without any error code return. You can update your powershell script to check the validate result and set the exit code to "1" if the result is "InvalidTemplate". This will make the powershell task fail when the template is valid.
Looks like the resource is defined multiple times in the template. You can remove it and its always a good practice from the PowerShell script to use Test-AzureRmResourceGroupDeployment and validate if the template is valid and has obtained all its parameters and then deploy using New-AzureRmResourceGroupDeployment
Like Eddie said you can try this inside a try{} catch block and return an exception or an exit code to make the VSTS Build pipeline fail, if the script fails.

Check if deployment exists on slot Staging

I'm trying to deploy a package on a role using UpgradeBySlotAsync on IDeploymentOperations' Deployments. When the deployment doesn't exist, it throws saying: 'A virtual network site cannot be added or removed during deployment update or upgrade'.
If I want to check on deployment's existence using GetBySlotAsync, it also throws when the deployment is not there.
Is there a way to check whether there is a deployment on Staging using IDeploymentOperations type? Something similar to Get-AzureDeployment in Powershell.

Resources