How to pass resource ID saved in Azure Devops variable group to a ARM template

Copper Contributor

I am trying to create a pipeline from a ARM template that I have exported while doing the operation manually in the portal. The ARM template has a parameter for ImageRefferenceID to specify the custom VM image stored in Azure compute gallery. 

In the pipeline I call a bash script which creates a deployment in Azure by using this ARM template.

The fully qualified resource Id of the image is stored in variable group with capital letters in the variable name, which as I understand should get passed to the script. But I get the following error:-

ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"Conflict","message":"{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The 'AzureAsyncOperationWaiting' resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"BadRequest\",\r\n            \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"LinkedInvalidPropertyId\\\",\\r\\n    \\\"message\\\": \\\"Property id ''***/versions/1.0.3'' at path 'properties.storageProfile.imageReference.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.\\\"\\r\\n  }\\r\\n}\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}"}]}}

 

If I run the deployment from Azure portal using the same ARM template and pass the exact same resource ID then it works.

 

In the error details I noticed that the Azure Devops replaces the whole front part of the Resource ID with "***" and only leaves the image version("1.0.3") at the end:-

Property id ''***/versions/1.0.3'

 Is that just because the error output is masking the subscription ID as that will be part of the Resource ID for security reasons? Or the value of ResourceID is not being passed correctly to the bash script?

 

How can I successfully pass the resource ID of the image to bash script, which will in turn pass it as parameter to the ARM template?

1 Reply
Image result for I am trying to create a pipeline from a ARM template that I have exported while doing the operation manually in the portal. The ARM template has a parameter for ImageRefferenceID to specify the custom VM image stored in Azure compute gallery. In the pipel Create pipeline If you haven't added a pipeline previously, you need to create a new pipeline. From your Azure DevOps organization, select Pipelines and New pipeline. Specify where your code is stored. ... From that source, select the repository that has the code for your project. Select the type of pipeline to create