CompositionalIT / farmer

Repeatable Azure deployments with ARM templates - made easy!
https://compositionalit.github.io/farmer
MIT License
526 stars 159 forks source link

Set Azure subscription #668

Open francotiveron opened 3 years ago

francotiveron commented 3 years ago

in 'deployment |> Deploy.execute resourceGroupName Deploy.NoParameters' we specify the resource group Is it possible to set the subscription using Farmer without invoking 'az set --subscription ' externally

isaacabraham commented 3 years ago

Currently, you need to do that. I think I mentioned in another issue that we intend to support this directly through the az arguments at deployment time, but currently it's not available in the API.

In the meantime, you could use Farmer to simply generate the ARM template and then call az however you want.

TheRSP commented 2 years ago

One solution I have found to this is to execute the az set inside the farmer script before the call to Deploy.execute. Something like this should work:

result {
  do! Farmer.Deploy.Az.az $"account set -s {subscriptionId}"
  return deployment |> Deploy.execute resourceGroupName Deploy.NoParameters
}

We do something similar (but wrapped up with a load more logic making it hard to copy-paste here) for our deployments.