Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.26k stars 753 forks source link

Simplify Bicep Deployments by Embedding Subscription and Tenant Context in Parameter Files #15504

Open trylvis opened 2 weeks ago

trylvis commented 2 weeks ago

Is your feature request related to a problem? Please describe.

In multi-tenant, multi-subscription environments, deploying Bicep templates requires switching Azure contexts frequently. Currently, we maintain a bicepparam file for each deployment, which includes most of the necessary parameters. However, specifying "Subscription ID" and "Tenant ID" is done externally, and we need to use az account set every time we switch tenants or subscriptions. This process can be cumbersome and error-prone.

Describe the solution you'd like

It would be helpful if subscriptionId and tenantId could be specified directly within the bicepparam file. The az deployment create command could then check these values in bicepparam for deployment context, defaulting to the current Azure CLI context if they aren’t provided.

This way, instead of first running az account set to adjust the context, then running az deployment create, we would only need to run az deployment create with context pulled directly from the parameter file, simplifying multi-environment deployments and reducing potential for errors.

asilverman commented 3 days ago

Have you considered using modules to model your scenario? You can start with a management group target scope deployment that triggers modules, each module is downscoped to the subscription and resource group using the scope property of a module