Pradeep
Pradeep

Reputation: 5540

How to pass the output of one ARM template to the input parameter of the next ARM template in Continuous Deployment using VSTS?

I have a ServiceBuswithQueue ARM template that has the output section like this below:

  "outputs": {
    "serviceBusNamespaceName": {
      "type": "string",
      "value": "[parameters('serviceBusNamespaceName')]"
    },
    "namespaceConnectionString": {
      "type": "string",
      "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
    },
    "sharedAccessPolicyPrimaryKey": {
      "type": "string",
      "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]"
    },
    "serviceBusQueueName": {
      "type": "string",
      "value": "[parameters('serviceBusQueueName')]"
    }
  }

For that I Created the Continuous Integration (CI) and Continuous Deployment (CD) in VSTS, In CD I have used the PowerShell task to deploy the above ARM template. But I want to pass the output of this ARM template like "$(serviceBusQueueName)" to input parameter of the next ARM template in Continuous Deployment.

In know the above scenario can achieved using ARM outputs in between the two ARM task in Continuous Deployment. But I don’t want it because currently I am using the PowerShell task to deploy the ARM template.

Before posting this question, I was researched and find the following links but those are not helpful to resolve my issue.

Azure ARM templates - using the output of other deployments

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

Can anyone please suggest me how to resolve the above issue?

Upvotes: 1

Views: 2811

Answers (2)

Gokhan
Gokhan

Reputation: 51

# Start the deployment
Write-Host "Starting deployment...";
$outputs = New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -Mode Incremental -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath;

foreach ($key in $outputs.Outputs.Keys){
    $type = $outputs.Outputs.Item($key).Type
    $value = $outputs.Outputs.Item($key).Value
    Write-Host "##vso[task.setvariable variable=$key;]$value"
}

You can display all the environment variables in a subsequent script:

Write-Host "Environment variables:"
gci env:* | sort-object name

Upvotes: 1

starian chen-MSFT
starian chen-MSFT

Reputation: 33728

You can override parameters by specifying corresponding parameters.

Override template parameter in the script

Upvotes: 1

Related Questions