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:
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).