You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/bicep-import.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,16 @@ title: Imports in Bicep
3
3
description: Describes how to import shared functionality and namespaces in Bicep.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-bicep
6
-
ms.date: 08/07/2024
6
+
ms.date: 08/20/2024
7
7
---
8
8
9
9
# Imports in Bicep
10
10
11
-
This article describes the syntax you use to export and import shared functionality, as well as namespaces for Bicep extensions.
11
+
This article describes the syntax you use to export and import shared functionality, and namespaces for Bicep extensions.
12
12
13
-
## Exporting types, variables and functions
13
+
## Export variables, types, and functions
14
14
15
-
The `@export()` decorator indicates that a given statement can be imported by another file. This decorator is only valid on type, variable, and function statements. Variable statements marked with `@export()` must be compile-time constants.
15
+
The `@export()` decorator indicates that a given statement can be imported by another file. This decorator is only valid on [`type`](./user-defined-data-types.md), [`var`](./variables.md), and [`func`](./user-defined-functions.md) statements. Variable statements marked with `@export()` must be compile-time constants.
16
16
17
17
The syntax for exporting functionality for use in other Bicep files is:
18
18
@@ -21,7 +21,7 @@ The syntax for exporting functionality for use in other Bicep files is:
21
21
<statement_to_export>
22
22
```
23
23
24
-
## Import types, variables, and functions
24
+
## Import variables, types, and functions
25
25
26
26
The syntax for importing functionality from another Bicep file is:
27
27
@@ -43,7 +43,7 @@ import * as <alias_name> from '<bicep_file_name>'
43
43
44
44
You can mix and match the preceding syntaxes. To access imported symbols using the wildcard syntax, you must use the `.` operator: `<alias_name>.<exported_symbol>`.
45
45
46
-
Only statements that have been [exported](#exporting-types-variables-and-functions) in the file being referenced are available to be imported.
46
+
Only statements that have been [exported](#export-variables-types-and-functions) in the file being referenced are available to be imported.
47
47
48
48
Functionality that has been imported from another file can be used without restrictions. For example, imported variables can be used anywhere a variable declared in-file would normally be valid.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/data-types.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Data types in Bicep
3
3
description: Describes the data types that are available in Bicep
4
4
ms.topic: reference
5
5
ms.custom: devx-track-bicep
6
-
ms.date: 07/16/2024
6
+
ms.date: 08/20/2024
7
7
---
8
8
9
9
# Data types in Bicep
@@ -319,7 +319,7 @@ is ${blocked}'''
319
319
320
320
## Union types
321
321
322
-
In Bicep, a union type allows the creation of a combined type consisting of a set of sub-types. An assignment is valid if any of the individual sub-type assignments are permitted. The `|` character separates individual sub-types using an _or_ condition. For example, the syntax _'a' | 'b'_ means that a valid assignment could be either _'a'_ or _'b'_. Union types are translated into the [allowed-value](../templates/definitions.md#allowed-values) constraint in Bicep, so only literals are permitted as members. Unions can include any number of literal-typed expressions.
322
+
In Bicep, a union type allows the creation of a combined type consisting of a set of subtypes. An assignment is valid if any of the individual subtype assignments are permitted. The `|` character separates individual subtypes using an _or_ condition. For example, the syntax _'a' | 'b'_ means that a valid assignment could be either _'a'_ or _'b'_. Union types are translated into the [allowed-value](../templates/definitions.md#allowed-values) constraint in Bicep, so only literals are permitted as members. Unions can include any number of literal-typed expressions.
323
323
324
324
```bicep
325
325
type color = 'Red' | 'Blue' | 'White'
@@ -335,7 +335,7 @@ Type unions must be reducible to a single ARM type, such as 'string', 'int', or
335
335
type foo = 'a' | 1
336
336
```
337
337
338
-
Any type expression can be used as a sub-type in a union type declaration (between `|` characters). For example, the following examples are all valid:
338
+
Any type expression can be used as a subtype in a union type declaration (between `|` characters). For example, the following examples are all valid:
339
339
340
340
```bicep
341
341
type foo = 1 | 2
@@ -379,13 +379,13 @@ There are some limitations with union type.
379
379
```
380
380
381
381
* Only literals are permitted as members.
382
-
* All literals must be of the same primitive data type (e.g., all strings or all integers).
382
+
* All literals must be of the same primitive data type (for example, all strings or all integers).
383
383
384
384
The union type syntax can be used in [user-defined data types](./user-defined-data-types.md).
385
385
386
386
## Secure strings and objects
387
387
388
-
Secure string uses the same format as string, and secure object uses the same format as object. With Bicep, you add the `@secure()`[decorator](./parameters.md#decorators) to a string or object.
388
+
Secure string uses the same format as string, and secure object uses the same format as object. With Bicep, you add the `@secure()`[decorator](./parameters.md#use-decorators) to a string or object.
389
389
390
390
When you set a parameter to a secure string or secure object, the value of the parameter isn't saved to the deployment history and isn't logged. However, if you set that secure value to a property that isn't expecting a secure value, the value isn't protected. For example, if you set a secure string to a tag, that value is stored as plain text. Use secure strings for passwords and secrets.
In a module, you can specify a scope that is different than the scope for the rest of the Bicep file. For more information, see [Configure module scope](modules.md#set-module-scope)
101
106
107
+
## Decorators
108
+
109
+
You can add one or more decorators for each of the following elements:
110
+
111
+
*[param](#parameters)
112
+
*[var](#variables)
113
+
*[resource](#resources)
114
+
*[module](#modules)
115
+
*[output](#outputs)
116
+
*[func](#functions)
117
+
*[type](#types)
118
+
119
+
| Decorator | Apply to element | Apply to data type | Argument | Description |
120
+
| --------- | ---- | ----------- | ------- |
121
+
| allowed |[param](./parameters.md#allowed-values)| all | array | Use this decorator to make sure the user provides correct values. This decorator is only permitted on `param` statements. To declare that a property must be one of a set of predefined values in a [`type`](./user-defined-data-types.md) or [`output`](./outputs.md) statement, use [union type syntax](./data-types.md#union-types). Union type syntax can also be used in `param` statements.|
122
+
| batchSize |[resource](./resource-declaration.md#batchsize), [module](./modules.md#batchsize)| N/A | integer | Set up instances to deploy sequentially. |
123
+
| description |[param](./parameters.md#description), [var](./variables.md#description), [resource](./resource-declaration.md#description), [module](./modules.md#description), [output](./outputs.md#description), [type](./user-defined-data-types.md#description), [func](./user-defined-functions.md#description)| all | string | Provide descriptions for the elements. Markdown-formatted text can be used for the description text. |
124
+
| discriminator |[param](./parameters.md#discriminator), [type](./user-defined-data-types.md#discriminator), [output](./outputs.md#discriminator)| object | string | Use this decorator to ensure the correct subclass is identified and managed. For more information, see [Custom-tagged union data type](./data-types.md#custom-tagged-union-data-type).|
125
+
| export |[var](./variables.md#export), [type](./user-defined-data-types.md#export), [func](./user-defined-functions.md#export)| all | none| Indicates that the element can be imported by another Bicep file. |
126
+
| maxLength |[param](./parameters.md#length-constraints), [output](./outputs.md#length-constraints)| array, string | int | The maximum length for string and array elements. The value is inclusive. |
127
+
| maxValue |[param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints)| int | int | The maximum value for the integer elements. This value is inclusive. |
128
+
| metadata |[param](./parameters.md#metadata), [output](./outputs.md#metadata)| all | object | Custom properties to apply to the elements. Can include a description property that is equivalent to the description decorator. |
129
+
| minLength |[param](./parameters.md#length-constraints), [output](./outputs.md#length-constraints)| array, string | int | The minimum length for string and array elements. The value is inclusive. |
130
+
| minValue |[param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints)| int | int | The minimum value for the integer elements. This value is inclusive. |
131
+
| sealed |[param](./parameters.md#sealed), [type](./user-defined-data-types.md#sealed), [output](./outputs.md#sealed)| object | none | Elevate [BCP089](./diagnostics/bcp089.md) from a warning to an error when a property name of a use-define data type is likely a typo. For more information, see [Elevate error level](./user-defined-data-types.md#elevate-error-level). |
132
+
| secure |[param](./parameters.md#secure-parameters)| string, object | none | Marks the parameter as secure. The value for a secure parameter isn't saved to the deployment history and isn't logged. For more information, see [Secure strings and objects](data-types.md#secure-strings-and-objects). |
133
+
134
+
## Parameters
135
+
136
+
Use parameters for values that need to vary for different deployments. You can define a default value for the parameter that is used if no value is provided during deployment.
137
+
138
+
For example, you can add a SKU parameter to specify different sizes for a resource. You might pass in different values depending on whether you're deploying to test or production.
139
+
140
+
```bicep
141
+
param storageSKU string = 'Standard_LRS'
142
+
```
143
+
144
+
The parameter is available for use in your Bicep file.
145
+
146
+
```bicep
147
+
sku: {
148
+
name: storageSKU
149
+
}
150
+
```
151
+
152
+
You can add one or more decorators for each parameter. For more information, see [Use decorators](./parameters.md#use-decorators).
153
+
154
+
For more information, see [Parameters in Bicep](./parameters.md).
155
+
156
+
## Variables
157
+
158
+
You can make your Bicep file more readable by encapsulating complex expressions in a variable. For example, you might add a variable for a resource name that is constructed by concatenating several values together.
159
+
160
+
```bicep
161
+
var uniqueStorageName = '${storagePrefix}${uniqueString(resourceGroup().id)}'
162
+
```
163
+
164
+
Apply this variable wherever you need the complex expression.
You can add one or more decorators for each user-defined data type. For more information, see [Use decorators](./user-defined-data-types.md#use-decorators).
205
+
131
206
For more information, see [User-defined data types](./user-defined-data-types.md).
For more information, see [User-defined functions](./user-defined-functions.md).
144
219
145
-
## Parameters
146
-
147
-
Use parameters for values that need to vary for different deployments. You can define a default value for the parameter that is used if no value is provided during deployment.
148
-
149
-
For example, you can add a SKU parameter to specify different sizes for a resource. You might pass in different values depending on whether you're deploying to test or production.
150
-
151
-
```bicep
152
-
param storageSKU string = 'Standard_LRS'
153
-
```
154
-
155
-
The parameter is available for use in your Bicep file.
156
-
157
-
```bicep
158
-
sku: {
159
-
name: storageSKU
160
-
}
161
-
```
162
-
163
-
For more information, see [Parameters in Bicep](./parameters.md).
164
-
165
-
## Parameter decorators
166
-
167
-
You can add one or more decorators for each parameter. These decorators describe the parameter and define constraints for the values that are passed in. The following example shows one decorator but many others are available.
168
-
169
-
```bicep
170
-
@allowed([
171
-
'Standard_LRS'
172
-
'Standard_GRS'
173
-
'Standard_ZRS'
174
-
'Premium_LRS'
175
-
])
176
-
param storageSKU string = 'Standard_LRS'
177
-
```
178
-
179
-
For more information, including descriptions of all available decorators, see [Decorators](parameters.md#decorators).
180
-
181
-
## Variables
182
-
183
-
You can make your Bicep file more readable by encapsulating complex expressions in a variable. For example, you might add a variable for a resource name that is constructed by concatenating several values together.
184
-
185
-
```bicep
186
-
var uniqueStorageName = '${storagePrefix}${uniqueString(resourceGroup().id)}'
187
-
```
188
-
189
-
Apply this variable wherever you need the complex expression.
For more information, see [Variables in Bicep](./variables.md).
197
-
198
220
## Resources
199
221
200
222
Use the `resource` keyword to define a resource to deploy. Your resource declaration includes a symbolic name for the resource. You use this symbolic name in other parts of the Bicep file to get a value from the resource.
The symbolic name enables you to reference the module from somewhere else in the file. For example, you can get an output value from a module by using the symbolic name and the name of the output value.
283
307
284
-
For more information, see [Use Bicep modules](./modules.md).
285
-
286
-
## Resource and module decorators
287
-
288
-
You can add a decorator to a resource or module definition. The supported decorators are `batchSize(int)` and `description`. You can only apply it to a resource or module definition that uses a `for` expression.
289
-
290
-
By default, resources are deployed in parallel. When you add the `batchSize(int)` decorator, you deploy instances serially.
291
-
292
-
```bicep
293
-
@batchSize(3)
294
-
resource storageAccountResources 'Microsoft.Storage/storageAccounts@2023-04-01' = [for storageName in storageAccounts: {
295
-
...
296
-
}]
297
-
```
308
+
You can add one or more decorators for each module. For more information, see [Use decorators](./modules.md#use-decorators).
298
309
299
-
For more information, see [Deploy in batches](loops.md#deploy-in-batches).
310
+
For more information, see [Use Bicep modules](./modules.md).
300
311
301
312
## Outputs
302
313
@@ -306,6 +317,8 @@ Use outputs to return values from the deployment. Typically, you return a value
You can add one or more decorators for each output. For more information, see [Use decorators](./outputs.md#use-decorators).
321
+
309
322
For more information, see [Outputs in Bicep](./outputs.md).
310
323
311
324
## Loops
@@ -423,7 +436,7 @@ The preceding example is equivalent to the following JSON.
423
436
424
437
## Multiple-line declarations
425
438
426
-
You can now use multiple lines in function, array and object declarations. This feature requires [Bicep CLI version 0.7.X or higher](./install.md).
439
+
You can now use multiple lines in function, array, and object declarations. This feature requires [Bicep CLI version 0.7.X or higher](./install.md).
427
440
428
441
In the following example, the `resourceGroup()` definition is broken into multiple lines.
429
442
@@ -438,7 +451,7 @@ See [Arrays](./data-types.md#arrays) and [Objects](./data-types.md#objects) for
438
451
## Known limitations
439
452
440
453
* No support for the concept of apiProfile, which is used to map a single apiProfile to a set apiVersion for each resource type.
441
-
* User-defined functions are not supported at the moment. However, an experimental feature is currently accessible. For more information, see [User-defined functions in Bicep](./user-defined-functions.md).
454
+
* User-defined functions aren't supported at the moment. However, an experimental feature is currently accessible. For more information, see [User-defined functions in Bicep](./user-defined-functions.md).
442
455
* Some Bicep features require a corresponding change to the intermediate language (Azure Resource Manager JSON templates). We announce these features as available when all of the required updates have been deployed to global Azure. If you're using a different environment, such as Azure Stack, there may be a delay in the availability of the feature. The Bicep feature is only available when the intermediate language has also been updated in that environment.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/linter-rule-secure-secrets-in-parameters.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.date: 03/20/2024
8
8
9
9
# Linter rule - secure secrets in parameters
10
10
11
-
This rule finds parameters whose names look like secrets but without the [secure decorator](./parameters.md#decorators), for example: a parameter name contains the following keywords:
11
+
This rule finds parameters whose names look like secrets but without the [secure decorator](./parameters.md#use-decorators), for example: a parameter name contains the following keywords:
12
12
13
13
- password
14
14
- pwd
@@ -24,7 +24,7 @@ Use the following value in the [Bicep configuration file](bicep-config-linter.md
24
24
25
25
## Solution
26
26
27
-
Use the [secure decorator](./parameters.md#decorators) for the parameters that contain secrets. The secure decorator marks the parameter as secure. The value for a secure parameter isn't saved to the deployment history and isn't logged.
27
+
Use the [secure decorator](./parameters.md#use-decorators) for the parameters that contain secrets. The secure decorator marks the parameter as secure. The value for a secure parameter isn't saved to the deployment history and isn't logged.
28
28
29
29
The following example fails this test because the parameter name may contain secrets.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/loops.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -309,7 +309,7 @@ By default, Azure resources are deployed in parallel. When you use a loop to cre
309
309
310
310
You might not want to update all instances of a resource type at the same time. For example, when updating a production environment, you may want to stagger the updates so only a certain number are updated at any one time. You can specify that a subset of the instances be batched together and deployed at the same time. The other instances wait for that batch to complete.
311
311
312
-
To serially deploy instances of a resource, add the [batchSize decorator](./file.md#resource-and-module-decorators). Set its value to the number of instances to deploy concurrently. A dependency is created on earlier instances in the loop, so it doesn't start one batch until the previous batch completes.
312
+
To serially deploy instances of a resource, add the [batchSize decorator](./file.md#decorators). Set its value to the number of instances to deploy concurrently. A dependency is created on earlier instances in the loop, so it doesn't start one batch until the previous batch completes.
0 commit comments