Hi team,
I don't really understand why the Azure Resource Group Deployment tasks don't capture the "outputs" property of an ARM deployment template..
The CLI and PowerShell both return this object so that we can use these values in subsequent steps.
In VSTS, using the built-in task, I have to script my own "Get" and then create custom VSTS environment variables.
This seems like an inconsistency between the CLI, PowerShell and the VSTS task.
Are there any plans to add this to the task or what is the reasoning behind not adding this?
Cheers
Actually, I just found https://github.com/Microsoft/vsts-tasks/blob/d226e225e69338c179bdf087d82bd7158e456193/Tasks/AzureResourceGroupDeployment/operations/ResourceGroup.ts#L405
Why is this commented out?
You have correctly identified that we have plans for enabling this feature. However, it is aligned to work with another in-preview feature https://github.com/Microsoft/vsts-agent/blob/4ae90b42c97c285a1a83541fb81872cc0ba0c14d/docs/preview/outputvariable.md . We hope to roll-it out soon..
@sachinma awesome, thanks for confirmation. That will mean I can soon remove my custom code.
Reopening it until this is deployed.
@sachinma How soon is soon, are we talking days, weeks, or months? We wanted to use outputs to look up the private keys of various resources we create in the template and are at the decision point of scrapping the idea, doing a workaround like davidobrian1985 did, or waiting for this feature to become available in preview in VSTS.
It should get enabled with our current ongoing deployment, which usually takes around 2-3 weeks to get deployed on all the scale units.
@bansalaseem Once it is deployed will it show up in the version dropdown as 3.* (preview), just 3.*, or will it be part of 2.*?
The current plan is to have it with 2.* version
Any idea when this will be released? I really need this functionality for my project asap. I see it was a part of version 1, but not version 2?
@sachinma you say it is about to roll out, but I can't find any branch in the repo that touches the output code since c316063fcca3e7bd53697c41d4d837314496545e was put in to comment out the code. I figured that if it is deploying "soon" at least there would be a branch or PR waiting to be merged in that enables it.
@leftler for now I found a workaround, not sure if you have one yet. But I added an Azure Powershell inline script task with the following code to get the output variables:
$outputs = (
Get-AzureRmResourceGroupDeployment -ResourceGroupName $(ApplicationName) |
Where-Object -Property Outputs -ne $null |
Sort-Object -Property Timestamp |
Select-Object -Last 1
).Outputs
$val = $outputs.dbConnString.value
write-host "Connectiong string: $val"
write-host "##vso[task.setvariable variable=DatabaseSetting.ConnectionString]$val"
@leftler We are testing that feature out locally first, by enabling that Feature Flag on some accounts and checking if the functionality is fine. We were having some trouble doing that, so it is going to take some more time. Till then, I hope the work around which @joe45sp suggested works for you.
Thank you for your patience.
Hey Guys,
Any update here? Cheers.
I also would like to know if there is any update on this? Anything I can do to contribute to getting this pushed into production or preview quicker?
I have added an outputs section in the task definition, where you can provide a name for the variable for the output variable which will contain the outputs section of the current deployment object in string format. You can use the “ConvertFrom-Json” PowerShell cmdlet to parse the JSON object and access the individual output values in the further steps of your build/release.
You'll start seeing this change within next 3 weeks.
Declared a variable PsOutput. and for my next powershell task, tried passing
-postlink $(PsOutput)
but it gives exception as:
-postLink {"postqueryTo":{"type": ...
@aakash1906 refer to this issue: https://github.com/Microsoft/vsts-tasks/issues/6988 for updates
Regarding the question by @aakash1906, found an example of capturing and making individual output items available to subsequent tasks: https://stackoverflow.com/a/49893304/7568572
@aakash1906 you may add single quotes before passing the value to the PS script:
-postlink '$(PsOutput)'
Most helpful comment
I have added an outputs section in the task definition, where you can provide a name for the variable for the output variable which will contain the outputs section of the current deployment object in string format. You can use the “ConvertFrom-Json” PowerShell cmdlet to parse the JSON object and access the individual output values in the further steps of your build/release.
You'll start seeing this change within next 3 weeks.