Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use ARM 'outputs' values another release task?

Tags:

I have an ARM template that has and outputs section like the following:

"outputs": {     "sqlServerFqdn": {         "type": "string",         "value": "[reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName]"     },     "primaryConnectionString": {         "type": "string",         "value": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('databaseName'), ';User Id=', parameters('administratorLogin'), '@', variables('sqlserverName'), ';Password=', parameters('administratorLoginPassword'), ';')]"     },     "envResourceGroup": {         "type": "string",         "value": "[parameters('hostingPlanName')]"     } } 

I have a Azure Resource Group Deployment task that uses the template. I then want to use the variable $(sqlServerFqdn) in the next task for configuration. The variable doesn't seem to just populate and I cannot find anywhere that tells me how to use 'outputs' values on release.

What do I need to do to get the variable to populate for use in configuring tasks after this ARM template runs? An example would be in the parameters to a powershell script task or another ARM template.

like image 366
AC4 Avatar asked Apr 29 '16 22:04

AC4


1 Answers

VSTS Azure Resource Group Deployment task has outputs section now (since January 2018). So you can set variable name in Deployment outputs of Azure Resource Group Deployment task to, for example, ResourceGroupDeploymentOutputs and add PowerShell Script task with the following inline script:

# Make outputs from resource group deployment available to subsequent tasks  $outputs = ConvertFrom-Json $($env:ResourceGroupDeploymentOutputs) foreach ($output in $outputs.PSObject.Properties) {   Write-Host "##vso[task.setvariable variable=RGDO_$($output.Name)]$($output.Value.value)" } 

And in subsequent tasks you can use your template variables. So, for example, if you have sqlServerFqdn variable in your template it will be available as $(RGDO_sqlServerFqdn) after PowerShell Script task is completed.

like image 177
oderibas Avatar answered Sep 28 '22 06:09

oderibas