0
votes

I want to deploy the same Infrastructure (from an ARM Template) to multiple Azure subscriptions.

During my endeavors, I couldn't find the possibility to override the selected Subscription at queue time? for e.g. using a variable like for normal fields $(AzureSubscriptions).

enter image description here tl;dr how to select one of the values at queue time without needing to edit the build?

If this is not possible what would you suggest as a good solution? Manually execute commands with an AzCLI script?

1

1 Answers

1
votes

The subscription can not be changed during build queuing.

But there are some workarounds for you to refer:

Option 1: execute commands as you mentioned.

Option 2: use custom conditions

You can add multiple Azure Resource Group Deployment tasks with different subscriptions. And execute one of them by custom conditions.

Assume there are two subscriptions can be available, you can add two Azure Resource Group Deployment tasks and select the two subscription separately.

Then add two variables (such as var1 and var2) both with the value 0:

enter image description here

Add custome condtions for the two two Azure Resource Group Deployment tasks:

  • For the first two Azure Resource Group Deployment task (selecting subscription1), add the custom condition:

      and(succeeded(), eq(variables['var1'], '1'))
    
  • For the second two Azure Resource Group Deployment task (selecting subscription2), add the custom condition:

      and(succeeded(), eq(variables['var2'], '1'))
    

Now if you are relady to execute Azure Resource Group Deployment task for a certain subscription, change the related variable’s value as 1.

Such as if you want to select subscription1, then change var1 value as 1 (keep var2 value as 0). If you want to select subscription2, then change var2 value as 1 (keep var1 value as 0).