0
votes

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?

2
Do you mean you are deploying ARM templates together in a PowerShell task?starian chen-MSFT
Yes Starian, currently I am using PowerShell task to deploy the ARM templates.Pradeep
Can you use the output directly? For example: $r=New-AzureRmResourceGroupDeployment ...., then you can access $r directly in the sample script.starian chen-MSFT
@starianchen-MSFT, Actually my first ARM template will give the output as "serviceBusNamespaceName". but I want to use the output of the first ARM templates into input parameter of the next ARM template.Pradeep
You can override parameters.starian chen-MSFT

2 Answers

1
votes

You can override parameters by specifying corresponding parameters.

Override template parameter in the script

1
votes
# 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