Skip to content

Commit 1730be5

Browse files
Merge pull request #296346 from LiSeda/LS-batch10
LS_Bicep_batch 10
2 parents 8da3d3d + c872f86 commit 1730be5

File tree

5 files changed

+115
-118
lines changed

5 files changed

+115
-118
lines changed

articles/azure-resource-manager/bicep/deploy-to-resource-group.md

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
---
22
title: Use Bicep to deploy resources to resource groups
3-
description: Describes how to deploy resources in a Bicep file. It shows how to target more than one resource group.
3+
description: Learn how to deploy resources in a Bicep file and how to target more than one resource group.
44
ms.topic: how-to
55
ms.custom: devx-track-bicep
6-
ms.date: 02/10/2025
6+
ms.date: 03/25/2025
77
---
88

9-
# Resource group deployments with Bicep files
9+
# Use Bicep to deploy resources to resource groups
1010

1111
This article describes how to set scope with Bicep when deploying to a resource group. For more information, see [Understand scope](../management/overview.md#understand-scope).
1212

1313
## Supported resources
1414

15-
Most resources can be deployed to a resource group. For a list of available resources, see [ARM template reference](/azure/templates).
15+
Most resources can be deployed to a resource group. For a list of available resources, reference the guidance for [ARM templates](/azure/templates).
1616

1717
## Set scope
1818

19-
By default, a Bicep file is scoped to the resource group. If you want to explicitly set the scope, use:
19+
A Bicep file is scoped to the resource group by default. If you want to explicitly set the scope, use:
2020

2121
```bicep
2222
targetScope = 'resourceGroup'
2323
```
2424

25-
But, setting the target scope to resource group is unnecessary because that scope is used by default.
25+
However, setting the target scope to resource group isn't necessary because that scope is used by default.
2626

2727
## Deployment commands
2828

@@ -40,7 +40,7 @@ az deployment group create \
4040
--parameters storageAccountType=Standard_GRS
4141
```
4242

43-
# [PowerShell](#tab/azure-powershell)
43+
# [Azure PowerShell](#tab/azure-powershell)
4444

4545
For the PowerShell deployment command, use [New-AzResourceGroupDeployment](/powershell/module/az.resources/new-azresourcegroupdeployment). The following example deploys a template to create a resource group. The resource group you specify in the `-ResourceGroupName` parameter is the **target resource group**.
4646

@@ -54,27 +54,27 @@ New-AzResourceGroupDeployment `
5454

5555
---
5656

57-
For more detailed information about deployment commands and options for deploying ARM templates, see:
57+
For more information about deployment commands and options for deploying ARM templates, see:
5858

59-
* [Deploy resources with ARM templates and Azure CLI](deploy-cli.md)
60-
* [Deploy resources with ARM templates and Azure PowerShell](deploy-powershell.md)
61-
* [Deploy ARM templates from Cloud Shell](deploy-cloud-shell.md)
59+
- [How to use Azure Resource Manager (ARM) deployment templates with Azure CLI](deploy-cli.md)
60+
- [Deploy resources with ARM templates and Azure PowerShell](deploy-powershell.md)
61+
- [Deploy ARM templates from Cloud Shell](deploy-cloud-shell.md)
6262

6363
## Deployment scopes
6464

6565
In a Bicep file, all resources declared with the [`resource`](./resource-declaration.md) keyword must be deployed at the same scope as the deployment. For a resource group deployment, this means all `resource` declarations in the Bicep file must be deployed to the same resource group or as a child or extension resource of a resource in the same resource group as the deployment.
6666

6767
However, this restriction doesn't apply to [`existing`](./existing-resource.md) resources. You can reference existing resources at a different scope than the deployment.
6868

69-
To deploy resources at multiple scopes within a single deployment, use [modules](./modules.md). Deploying a module triggers a "nested deployment," allowing you to target different scopes. The user deploying the parent Bicep file must have the necessary permissions to initiate deployments at those scopes.
69+
To deploy resources at multiple scopes within a single deployment, use [modules](./modules.md). Deploying a module triggers a nested deployment, allowing you to target different scopes. The user deploying the parent Bicep file must have the necessary permissions to initiate deployments at those scopes.
7070

71-
You can deploy a resource from within a resource-group scope Bicep file at the following scopes:
71+
You can deploy a resource from within a resource-group-scope Bicep file at the following scopes:
7272

73-
* [The same resource group](#scope-to-target-resource-group)
74-
* [Other resource groups in the same subscription](#scope-to-different-resource-group)
75-
* [Other resource groups in other subscriptions](#scope-to-different-resource-group)
76-
* [The subscription](#scope-to-subscription)
77-
* [The tenant](#scope-to-tenant)
73+
- [The same resource group](#scope-to-target-resource-group)
74+
- [Other resource groups in the same subscription](#scope-to-different-resource-group)
75+
- [Other resource groups in other subscriptions](#scope-to-different-resource-group)
76+
- [The subscription](#scope-to-subscription)
77+
- [The tenant](#scope-to-tenant)
7878

7979
### Scope to target resource group
8080

@@ -91,11 +91,11 @@ For an example template, see [Deploy to target resource group](#deploy-to-target
9191

9292
### Scope to different resource group
9393

94-
To deploy resources to a resource group that isn't the target resource group, add a [module](modules.md). Use the [resourceGroup function](bicep-functions-scope.md#resourcegroup) to set the `scope` property for that module.
94+
To deploy resources to a resource group that isn't the target resource group, add a [module](modules.md). Use the [`resourceGroup` function](bicep-functions-scope.md#resourcegroup) to set the `scope` property for that module.
9595

96-
If the resource group is in a different subscription, provide the subscription ID and the name of the resource group. If the resource group is in the same subscription as the current deployment, provide only the name of the resource group. If you don't specify a subscription in the [resourceGroup function](bicep-functions-scope.md#resourcegroup), the current subscription is used.
96+
If the resource group is in a different subscription, provide the subscription ID and the name of the resource group. If the resource group is in the same subscription as the current deployment, provide only the name of the resource group. If you don't specify a subscription in the `resourceGroup` function, the current subscription is used.
9797

98-
The following example shows a module that targets a resource group in a different subscription.
98+
The following example shows a module that targets a resource group in a different subscription:
9999

100100
```bicep
101101
param otherResourceGroup string
@@ -108,7 +108,7 @@ module exampleModule 'module.bicep' = {
108108
}
109109
```
110110

111-
The next example shows a module that targets a resource group in the same subscription.
111+
The next example shows a module that targets a resource group in the same subscription:
112112

113113
```bicep
114114
param otherResourceGroup string
@@ -123,10 +123,10 @@ module exampleModule 'module.bicep' = {
123123
For an example template, see [Deploy to multiple resource groups](#deploy-to-multiple-resource-groups).
124124

125125
### Scope to subscription
126+
`
127+
To deploy resources to a subscription, add a module. Use the [`subscription` function](bicep-functions-scope.md#subscription) to set its `scope` property.
126128

127-
To deploy resources to a subscription, add a module. Use the [subscription function](bicep-functions-scope.md#subscription) to set its `scope` property.
128-
129-
To deploy to the current subscription, use the subscription function without a parameter.
129+
To deploy to the current subscription, use the `subscription` function without a parameter.
130130

131131
```bicep
132132
@@ -137,7 +137,7 @@ module exampleModule 'module.bicep' = {
137137
}
138138
```
139139

140-
To deploy to a different subscription, specify that subscription ID as a parameter in the subscription function.
140+
To deploy to a different subscription, specify that subscription ID as a parameter in the `subscription` function.
141141

142142
```bicep
143143
param otherSubscriptionID string
@@ -149,15 +149,13 @@ module exampleModule 'module.bicep' = {
149149
}
150150
```
151151

152-
For an example template, see [Create resource group with Bicep](create-resource-group.md).
153-
154152
### Scope to tenant
155153

156-
To create resources at the tenant, add a module. Use the [tenant function](bicep-functions-scope.md#tenant) to set its `scope` property.
154+
To create resources at the tenant, add a module. Use the [`tenant` function](bicep-functions-scope.md#tenant) to set its `scope` property.
157155

158156
The user deploying the template must have the [required access to deploy at the tenant](deploy-to-tenant.md#required-access).
159157

160-
The following example includes a module that is deployed to the tenant.
158+
The following example includes a module that deploys to the tenant:
161159

162160
```bicep
163161
// module deployed at tenant level
@@ -167,7 +165,7 @@ module exampleModule 'module.bicep' = {
167165
}
168166
```
169167

170-
Instead of using a module, you can set the scope to `tenant()` for some resource types. The following example deploys a management group at the tenant.
168+
Instead of using a module, you can set the scope to `tenant()` for some resource types. The following example deploys a management group at the tenant:
171169

172170
```bicep
173171
param mgName string = 'mg-${uniqueString(newGuid())}'
@@ -186,7 +184,7 @@ For more information, see [Management group](deploy-to-management-group.md#manag
186184

187185
## Deploy to target resource group
188186

189-
To deploy resources in the target resource group, define those resources in the `resources` section of the template. The following template creates a storage account in the resource group that is specified in the deployment operation.
187+
To deploy resources in the target resource group, define those resources in the `resources` section of the template. The following template creates a storage account in the resource group that's specified in the deployment operation:
190188

191189
```bicep
192190
@minLength(3)
@@ -226,10 +224,10 @@ output storageEndpoint object = stg.properties.primaryEndpoints
226224

227225
## Deploy to multiple resource groups
228226

229-
You can deploy to more than one resource group in a single Bicep file.
227+
You can deploy to more than one resource group in one Bicep file.
230228

231229
> [!NOTE]
232-
> You can deploy to **800 resource groups** in a single deployment. Typically, this limitation means you can deploy to one resource group specified for the parent template, and up to 799 resource groups in nested or linked deployments. However, if your parent template contains only nested or linked templates and doesn't itself deploy any resources, then you can include up to 800 resource groups in nested or linked deployments.
230+
> You can deploy up to **800 resource groups** in one deployment. Typically, this limitation means you can deploy to one resource group specified for the parent template and up to 799 resource groups in nested or linked deployments. However, if your parent template contains only nested or linked templates and doesn't itself deploy any resources, then you can include up to 800 resource groups in nested or linked deployments.
233231
234232
The following example deploys two storage accounts. The first storage account is deployed to the resource group specified in the deployment operation. The second storage account is deployed to the resource group specified in the `secondResourceGroup` and `secondSubscriptionID` parameters:
235233

@@ -264,7 +262,7 @@ module secondStorageAcct 'storage.bicep' = {
264262
}
265263
```
266264

267-
Both modules use the same Bicep file named **storage.bicep**.
265+
Both modules use the same Bicep file named **storage.bicep**:
268266

269267
```bicep
270268
param storageLocation string
@@ -283,12 +281,12 @@ resource storageAcct 'Microsoft.Storage/storageAccounts@2023-04-01' = {
283281

284282
## Create resource group
285283

286-
For information about creating resource groups, see [Create resource group with Bicep](create-resource-group.md).
284+
For an example template and more information about creating resource groups, see [Create resource group with Bicep](create-resource-group.md).
287285

288286
## Next steps
289287

290288
To learn about other scopes, see:
291289

292-
* [Subscription deployments](deploy-to-subscription.md)
293-
* [Management group deployments](deploy-to-management-group.md)
294-
* [Tenant deployments](deploy-to-tenant.md)
290+
- [Subscription deployments](deploy-to-subscription.md)
291+
- [Management group deployments](deploy-to-management-group.md)
292+
- [Tenant deployments](deploy-to-tenant.md)

0 commit comments

Comments
 (0)