Skip to content

Commit d97639d

Browse files
committed
revisions and redirects
1 parent 9321f0e commit d97639d

File tree

4 files changed

+51
-63
lines changed

4 files changed

+51
-63
lines changed

.openpublishing.redirection.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10068,6 +10068,31 @@
1006810068
"redirect_url": "/azure/azure-resource-manager/management/extension-resource-types",
1006910069
"redirect_document_id": false
1007010070
},
10071+
{
10072+
"source_path_from_root": "/articles/azure-resource-manager/bicep/loop-modules.md",
10073+
"redirect_url": "/azure/azure-resource-manager/bicep/loops",
10074+
"redirect_document_id": false
10075+
},
10076+
{
10077+
"source_path_from_root": "/articles/azure-resource-manager/bicep/loop-outputs.md",
10078+
"redirect_url": "/azure/azure-resource-manager/bicep/loops",
10079+
"redirect_document_id": false
10080+
},
10081+
{
10082+
"source_path_from_root": "/articles/azure-resource-manager/bicep/loop-properties.md",
10083+
"redirect_url": "/azure/azure-resource-manager/bicep/loops",
10084+
"redirect_document_id": false
10085+
},
10086+
{
10087+
"source_path_from_root": "/articles/azure-resource-manager/bicep/loop-resources.md",
10088+
"redirect_url": "/azure/azure-resource-manager/bicep/loops",
10089+
"redirect_document_id": false
10090+
},
10091+
{
10092+
"source_path_from_root": "/articles/azure-resource-manager/bicep/loop-variables.md",
10093+
"redirect_url": "/azure/azure-resource-manager/bicep/loops",
10094+
"redirect_document_id": false
10095+
},
1007110096
{
1007210097
"source_path_from_root": "/articles/azure-resource-manager/templates/compare-template-syntax.md",
1007310098
"redirect_url": "/azure/azure-resource-manager/bicep/compare-template-syntax",

articles/azure-resource-manager/bicep/loops.md

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.date: 10/19/2021
77

88
# Iterative loops in Bicep
99

10-
This article shows you how to use the `for` syntax to iterate over items in a collection. You can use loops to define multiple copies of a resource, property, variable, module, or output. Use loops to avoid repeating syntax in your Bicep file and to dynamically set the number of copies to create during deployment.
10+
This article shows you how to use the `for` syntax to iterate over items in a collection. You can use loops to define multiple copies of a resource, module, variable, property, or output. Use loops to avoid repeating syntax in your Bicep file and to dynamically set the number of copies to create during deployment.
1111

1212
### Microsoft Learn
1313

@@ -17,7 +17,7 @@ To learn more about loops, and for hands-on guidance, see [Build flexible Bicep
1717

1818
Loops can be declared by:
1919

20-
- Using an **integer index**. This option works when your scenario is: "I want to create this many instances." The [range function](bicep-functions-array.md#range) creates an array of integers from the start index and containing the number of specified elements. Within the loop, you can use the integer index to modify values. For more information, see [Integer index](#integer-index).
20+
- Using an **integer index**. This option works when your scenario is: "I want to create this many instances." The [range function](bicep-functions-array.md#range) creates an array of integers that begins at the start index and contains the number of specified elements. Within the loop, you can use the integer index to modify values. For more information, see [Integer index](#integer-index).
2121

2222
```bicep
2323
[for <index> in range(<startIndex>, <numberOfElements>): {
@@ -59,15 +59,15 @@ Loops can be declared by:
5959

6060
## Loop limits
6161

62-
Bicep loop has these limitations:
62+
Using loops in Bicep has these limitations:
6363

6464
- Loop iterations can't be a negative number or exceed 800 iterations.
6565
- Can't loop a resource with nested child resources. Change the child resources to top-level resources. See [Iteration for a child resource](#iteration-for-a-child-resource).
6666
- Can't loop on multiple levels of properties.
6767

6868
## Integer index
6969

70-
For a simple example of using an index, create a **variable** for an array of strings.
70+
For a simple example of using an index, create a **variable** that contains an array of strings.
7171

7272
```bicep
7373
param itemCount int = 5
@@ -154,38 +154,7 @@ resource storageAcct 'Microsoft.Storage/storageAccounts@2021-02-01' = [for name
154154

155155
The next example iterates over an array to define a property. It creates two subnets within a virtual network.
156156

157-
```bicep
158-
param rgLocation string = resourceGroup().location
159-
160-
var subnets = [
161-
{
162-
name: 'api'
163-
subnetPrefix: '10.144.0.0/24'
164-
}
165-
{
166-
name: 'worker'
167-
subnetPrefix: '10.144.1.0/24'
168-
}
169-
]
170-
171-
resource vnet 'Microsoft.Network/virtualNetworks@2020-07-01' = {
172-
name: 'vnet'
173-
location: rgLocation
174-
properties: {
175-
addressSpace: {
176-
addressPrefixes: [
177-
'10.144.0.0/20'
178-
]
179-
}
180-
subnets: [for subnet in subnets: {
181-
name: subnet.name
182-
properties: {
183-
addressPrefix: subnet.subnetPrefix
184-
}
185-
}]
186-
}
187-
}
188-
```
157+
::: code language="bicep" source="~/azure-docs-bicep-samples/samples/loops/loopproperty.bicep" highlight="23-28" :::
189158

190159
## Array and index
191160

@@ -254,7 +223,7 @@ output deployedNSGs array = [for (name, i) in orgNames: {
254223

255224
## Dictionary object
256225

257-
When you want to iterate over elements in a dictionary object, use the [items function](bicep-functions-array.md#items) to convert the object to an array. Use the `value` property to get properties on the objects.
226+
To iterate over elements in a dictionary object, use the [items function](bicep-functions-array.md#items), which converts the object to an array. Use the `value` property to get properties on the objects.
258227

259228
```bicep
260229
param nsgValues object = {
@@ -278,7 +247,7 @@ resource nsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = [for nsg in
278247

279248
For **resources and modules**, you can add an `if` expression with the loop syntax to conditionally deploy the collection.
280249

281-
The following example shows a nested loop combined with a filtered resource loop. Filters must be expressions that evaluate to a boolean value. In this example, a single condition is applied to all instances of the module.
250+
The following example shows a loop combined with a condition statement. In this example, a single condition is applied to all instances of the module.
282251

283252
```bicep
284253
param location string

articles/azure-resource-manager/bicep/outputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var user = {
3939
output stringOutput string = user['user-name']
4040
```
4141

42-
To return one of two values depending a condition in the deployment, use the the `?` operator. For more information, see [Conditional output](#conditional-output).
42+
When the value to return depends on a condition in the deployment, use the the `?` operator. For more information, see [Conditional output](#conditional-output).
4343

4444
```bicep
4545
output <name> <data-type> = <condition> ? <true-value> : <false-value>

articles/azure-resource-manager/bicep/resource-declaration.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,52 @@ This article describes the syntax you use to add a resource to your Bicep file.
1313

1414
## Declaration
1515

16-
Add a resource declaration by using the `resource` keyword. The values you provide in the declaration are described in more details in this article.
16+
Add a resource declaration by using the `resource` keyword. You set a symbolic name for the resource. The symbolic name isn't the same as the resource name. You use the symbolic name to reference the resource in other parts of your Bicep file.
1717

1818
```bicep
19-
resource <symbolic-name> '<resource-type>@<api-version>' = {
19+
resource <symbolic-name> '<full-type-name>@<api-version>' = {
2020
<resource-properties>
2121
}
2222
```
2323

24+
So, a declaration for a storage account can start with:
25+
26+
```bicep
27+
resource stg 'Microsoft.Storage/storageAccounts@2021-04-01' = {
28+
...
29+
}
30+
```
31+
32+
Symbolic names are case-sensitive. They may contain letters, numbers, and _; but can't start with a number.
33+
34+
For the available resource types and version, see [Bicep resource reference](/azure/templates/). Bicep doesn't support `apiProfile`, which is available in [Azure Resource Manager templates (ARM templates) JSON](../templates/syntax.md).
35+
2436
To conditionally deploy a resource, use the `if` syntax. For more information, see [Conditional deployment in Bicep](conditional-resource-deployment.md).
2537

2638
```bicep
27-
resource <symbolic-name> '<resource-type>@<api-version>' = if (condition) {
39+
resource <symbolic-name> '<full-type-name>@<api-version>' = if (condition) {
2840
<resource-properties>
2941
}
3042
```
3143

3244
To deploy more than one instance of a resource, use the `for` syntax. For more information, see [Iterative loops in Bicep](loops.md).
3345

3446
```bicep
35-
resource <symbolic-name> '<resource-type>@<api-version>' = [for <item> in <collection>: {
47+
resource <symbolic-name> '<full-type-name>@<api-version>' = [for <item> in <collection>: {
3648
<properties-to-repeat>
3749
}]
3850
```
3951

4052
You can also use the `for` syntax on the resource properties to create an array.
4153

4254
```bicep
43-
resource <symbolic-name> '<resource-type>@<api-version>' = {
55+
resource <symbolic-name> '<full-type-name>@<api-version>' = {
4456
properties: {
4557
<array-property>: [for <item> in <collection>: <value-to-repeat>]
4658
}
4759
}
4860
```
4961

50-
## Resource type and version
51-
52-
When adding a resource to your Bicep file, start by setting the resource type and API version. These values determine the other properties that are available for the resource.
53-
54-
The following example shows how to set the resource type and API version for a storage account. The example doesn't show the full resource declaration.
55-
56-
```bicep
57-
resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
58-
...
59-
}
60-
```
61-
62-
You set a symbolic name for the resource. In the preceding example, the symbolic name is `stg`. The symbolic name isn't the same as the resource name. You use the symbolic name to reference the resource in other parts of your Bicep file. Symbolic names are case-sensitive. They may contain letters, numbers, and _; but can't start with a number.
63-
64-
Bicep doesn't support `apiProfile`, which is available in [Azure Resource Manager templates (ARM templates) JSON](../templates/syntax.md).
65-
6662
## Resource name
6763

6864
Each resource has a name. When setting the resource name, pay attention to the [rules and restrictions for resource names](../management/resource-name-rules.md).
@@ -173,7 +169,7 @@ resource vm 'Microsoft.Compute/virtualMachines@2020-06-01' = {
173169

174170
The preceding properties are generic to most resource types. After setting those values, you need to set the properties that are specific to the resource type you're deploying.
175171

176-
Use intellisense or [template reference](/azure/templates/) to determine which properties are available and which ones are required. The following example sets the remaining properties for a storage account.
172+
Use intellisense or [Bicep resource reference](/azure/templates/) to determine which properties are available and which ones are required. The following example sets the remaining properties for a storage account.
177173

178174
```bicep
179175
resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
@@ -190,8 +186,6 @@ resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
190186
}
191187
```
192188

193-
To assign an array to a property, use the `for` syntax.
194-
195189
## Dependencies
196190

197191
When deploying resources, you may need to make sure some resources exist before other resources. For example, you need a logical SQL server before deploying a database. You establish this relationship by marking one resource as dependent on the other resource. Order of resource deployment can be influenced in two ways: [implicit dependency](#implicit-dependency) and [explicit dependency](#explicit-dependency)

0 commit comments

Comments
 (0)