d_zero
d_zero

Reputation: 21

What is 'azureRmConnection.Id' in this Azure Pipelines build yaml template and how do I use it?

Problem Summary

I'm trying to build and deploy a project to an Azure Web App. I've already setup the Azure Web App. For the build pipeline I've taken the following build YAML template from Microsoft:

https://github.com/microsoft/azure-pipelines-yaml/blob/master/templates/node.js-react-webapp-to-linux-on-azure.yml

I don't know what {{ azureRmConnection.Id }} in the variables section of the YAML template refers to or how to use it.

Background

The double-brace ({{ }}) syntax is used to evaluate expressions, whereas pipeline variables are referenced with dollar ($()) syntax. So I think azureRmConnection is something the build should already have access to rather than requiring a pipeline variable to be set.

What I've tried

The code

variables:

  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: '{{ azureRmConnection.Id }}'

Expected and actual results

Expected

I expect the build to have a valid azureRmConnection.Id and therefore not fail due to it being missing or invalid.

Actual

The build is failing with the following error:

There was a resource authorization issue: "The pipeline is not valid. Job Deploy: Step input azureSubscription references service connection {{ azureRmConnection.Id }} which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."

Upvotes: 0

Views: 632

Answers (2)

d_zero
d_zero

Reputation: 21

I tried creating a new pipeline using the 'Node.js React Web App to Linux on Azure' wizard. I did think I'd tried that already but I must have used a different one previously. This had several more stages in it.

The wizard allowed me to choose my Azure Web App and Azure Subscription from dropdown menus.

The variables look like this in the YAML now:

variables:
  azureSubscription: '1234xx56-xx7x-[...]'
  webAppName: 'my-azure-web-app-name'
  environmentName: 'my-azure-web-app-name'

azureSubscription is my Azure Subscription ID.

webAppName is the name of my Azure Web App that I had previously setup on the Azure Portal.

The build has now run successfully.

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72211

what you need to do is follow this link and create an AzureRm service connection and use its name in place of that placeholder:

azureSubscription: 'my-azurerm-connection-name-goes-here'

Upvotes: 1

Related Questions