Bicep Language - Beyond Basics - Scoped Deployment
When using ARM JSON templates, you can deploy to any of the four supported scopes – management groups, tenants, subscriptions, and resource groups. What you can deploy using ARM JSON templates differs between these different target scopes. For example, you can create resource groups at the subscription level only. You identify the target scope for an ARM JSON template using the $schema
element in the template. Each scope has a specific schema.
Bicep language too supports specifying scope within the bicep files using the targetScope
keyword. This keyword takes one or more values – resourceGroup, tenant, subscription, and managementGroup.
When the targetScope
value is set, Bicep knows what resources to expect within the file.
Here is an example of using the resource group resource in a subscription scoped Bicep file.
|
|
This, when compiled, produces the following ARM JSON representation.
|
|
This is how you deploy a subscription level template using Azure CLI.
|
|
You can mix scopes in a Bicep file by explicitly specifying scope property in a resource instance or module. Here is an example.
|
|
In the module specification, the scope property is set to the resource group being created in this template and that creates a dependency on the resource group as well.
This is a quick overview of scoped deployment template generation using Bicep. Hope you enjoyed reading this series of articles. This is the final article in this series and I will write more deep dive articles later. If you have suggestions for any specific content around Bicep, feel free to leave a comment.
Share on: