Setting output variable directly from AzureResourceManagerTemplateDeployment@3 deployment output value gives leading whitespace
See original GitHub issueRequired Information
Question, Bug, or Feature?
Type: Bug
Enter Task Name: AzureResourceManagerTemplateDeployment@3
Environment
- Server - Azure Pipelines
- Agent - Private, Ubuntu20.04
- Azure DevOps + VMSS
- VM-extension (Microsoft.Azure.DevOps.Pipelines.Agent - Microsoft.VisualStudio.Services.TeamServicesAgentLinux - 1.22)
Issue Description
Setting output variables with “##vso[task.setvariable]” using the deployment output values directly from AzureResourceManagerTemplateDeployment@3 task gives leading whitespace in the results.
- task: AzureResourceManagerTemplateDeployment@3
displayName: Deploy ExpressRoute Circuit
inputs:
<obfuscated>
deploymentMode: Incremental
deploymentOutputs: ercOutputs
- powershell: |
Write-Host "##vso[task.setvariable variable=ercId;isOutput=true]$(ercOutputs.ercId.value)"
Write-Host "##vso[task.setvariable variable=ercLocation;isOutput=true]$(ercOutputs.ercLocation.value)"
displayName: 'Write output variables'
name: ercVars
Next job using the output variables as stageDependencies:
- stage: MyNextStage
dependsOn:
- TheOtherStage
jobs:
- job: ExpressRouteGatewayAndConnection
displayName: 'Deploy Expressroute Gateway and Connection'
variables:
ercId: $[stageDependencies.ExpressRouteCircuit.DeployExpressRouteCircuit.outputs['ercVars.ercId']]
ercLocation: $[stageDependencies.ExpressRouteCircuit.DeployExpressRouteCircuit.outputs['ercVars.ercLocation']]
Task logs
The job preparation parameters result always have a leading whitespace, and I guess this is not intended. This seems to have made the parameter validation for my next job fail atleast.
Troubleshooting
I am fully aware that I can solve this by doing the traditional example.
$json = ConvertFrom-Json '$(ercOutputs)'
Write-Host "##vso[task.setvariable variable=ercId;isOutput=true]$($json.ercId.value)"
Write-Host "##vso[task.setvariable variable=ercLocation;isOutput=true]$($json.ercLocation.value)"
However if this could be used properly it would feel atleast a bit smoother working with the outputs.
Error logs
2022-05-04T14:38:29.1504100Z There were errors in your deployment. Error code: InvalidDeploymentParameterKey.
2022-05-04T14:38:29.1507327Z ##[error]One of the deployment parameters has an empty key. Please see https://aka.ms/resource-manager-parameter-files for details.
2022-05-04T14:38:29.1528085Z ##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
2022-05-04T14:38:29.1542329Z ##[error]Task failed while creating or updating the template deployment.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Outputs in ARM template - Azure Resource Manager
Define output values. The following example shows how to return a property from a deployed resource. Add the outputs section to the template....
Read more >Pass tags (with spaces) to an ARM template using Azure ...
In my pipeline for simplicity, I set the tags to a variable. pool: vmImage: 'ubuntu-latest' variables: - name: tags value: ("Location Region= ...
Read more >Stop Wasting Time: Parse ARM Output Variables Easier
In this article, learn how to wrangle ARM output variables in your Azure DevOps pipelines with some PowerShell!
Read more >Jinja2 Tutorial - Part 3 - Whitespace control |
Jinja2 Tutorial - Part 1 - Introduction and variable substitution ... I rendered whitespaces in the template as well as the output text....
Read more >Using ARM Templates in C# Integration Tests - Isoline Ltd.
I'll limit the amount of resources in this sample, so it's easier to ... arm output variables and update/create them in the variable...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No worries, I just discovered the related bug at roughly the same time as you. And was already working on a pr to fix it.
The related PR is still open… https://github.com/microsoft/azure-pipelines-tasks/pull/16283
@DenisRumyantsev you’re the last one to commit to this repo, how do we get this PR approved?