Skip to content

Commit db3618b

Browse files
committed
update
1 parent 3699de5 commit db3618b

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ You can add one or more decorators for each of the following elements:
125125
| description | [func](./user-defined-functions.md#description), [param](./parameters.md#description), [module](./modules.md#description), [output](./outputs.md#description), [resource](./resource-declaration.md#description), [type](./user-defined-data-types.md#description), [var](./variables.md#description) | all | string | Provide descriptions for the elements. Markdown-formatted text can be used for the description text. |
126126
| 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).|
127127
| export | [func](./user-defined-functions.md#export), [type](./user-defined-data-types.md#export), [var](./variables.md#export) | all | none| Indicates that the element can be imported by another Bicep file. |
128-
| 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. |
129-
| maxValue | [param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints) | int | int | The maximum value for the integer elements. This value is inclusive. |
130-
| 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. |
131-
| 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. |
132-
| minValue | [param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints) | int | int | The minimum value for the integer elements. This value is inclusive. |
128+
| maxLength | [param](./parameters.md#length-constraints), [output](./outputs.md#length-constraints), [type](./user-defined-data-types.md#length-constraints) | array, string | int | The maximum length for string and array elements. The value is inclusive. |
129+
| maxValue | [param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints), [type](./user-defined-data-types.md#integer-constraints) | int | int | The maximum value for the integer elements. This value is inclusive. |
130+
| metadata | [func](./user-defined-functions.md#metadata), [output](./outputs.md#metadata), [param](./parameters.md#metadata), [type](./user-defined-data-types.md#metadata) | all | object | Custom properties to apply to the elements. Can include a description property that is equivalent to the description decorator. |
131+
| minLength | [param](./parameters.md#length-constraints), [output](./outputs.md#length-constraints), [type](./user-defined-data-types.md#length-constraints) | array, string | int | The minimum length for string and array elements. The value is inclusive. |
132+
| minValue | [param](./parameters.md#integer-constraints), [output](./outputs.md#integer-constraints), [type](./user-defined-data-types.md#integer-constraints) | int | int | The minimum value for the integer elements. This value is inclusive. |
133133
| 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). |
134-
| secure | [param](./parameters.md#secure-parameters), [type](./user-defined-data-types.md#sealed) | 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). |
134+
| secure | [param](./parameters.md#secure-parameters), [type](./user-defined-data-types.md#secure-types) | 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). |
135135

136136
## Parameters
137137

articles/azure-resource-manager/bicep/user-defined-data-types.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Decorators are written in the format `@expression` and are placed above the decl
237237
| [description](#description) | string | Provide descriptions for the user-defined data type. |
238238
| [discriminator](#discriminator) | string | Use this decorator to ensure the correct subclass is identified and managed. |
239239
| [export](#export) | none | Indicates that the user-defined data type is available for import by another Bicep file. |
240+
| [metadata](#metadata) | all | object | Custom properties to apply to the data type. Can include a description property that is equivalent to the description decorator. |
240241
| [sealed](#sealed) | 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](#elevate-error-level).|
241242
| [secure](#secure-parameters) | string, object | none | Marks the types as secure. The value for a secure type 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). |
242243

@@ -268,6 +269,49 @@ Markdown-formatted text can be used for the description text.
268269

269270
Use `@export()` to share the user-defined data type with other Bicep files. For more information, see [Export variables, types, and functions](./bicep-import.md#export-variables-types-and-functions).
270271

272+
### Integer constraints
273+
274+
You can set minimum and maximum values for integer type. You can set one or both constraints.
275+
276+
```bicep
277+
@minValue(1)
278+
@maxValue(12)
279+
type month int
280+
```
281+
282+
### Length constraints
283+
284+
You can specify minimum and maximum lengths for string and array types. You can set one or both constraints. For strings, the length indicates the number of characters. For arrays, the length indicates the number of items in the array.
285+
286+
The following example declares two type. One type is for a storage account name that must have 3-24 characters. The other type is an array that must have from 1-5 items.
287+
288+
```bicep
289+
@minLength(3)
290+
@maxLength(24)
291+
type storageAccountName string
292+
293+
@minLength(1)
294+
@maxLength(5)
295+
type appNames array
296+
```
297+
298+
### Metadata
299+
300+
If you have custom properties that you want to apply to a user-defined data type, add a metadata decorator. Within the metadata, define an object with the custom names and values. The object you define for the metadata can contain properties of any name and type.
301+
302+
You might use this decorator to track information about the data type that doesn't make sense to add to the [description](#description).
303+
304+
```bicep
305+
@description('Configuration values that are applied when the application starts.')
306+
@metadata({
307+
source: 'database'
308+
contact: 'Web team'
309+
})
310+
type settings object
311+
```
312+
313+
When you provide a `@metadata()` decorator with a property that conflicts with another decorator, that decorator always takes precedence over anything in the `@metadata()` decorator. So, the conflicting property within the `@metadata()` value is redundant and will be replaced. For more information, see [No conflicting metadata](./linter-rule-no-conflicting-metadata.md).
314+
271315
### Sealed
272316

273317
See [Elevate error level](#elevate-error-level).

articles/azure-resource-manager/bicep/user-defined-functions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Decorators are written in the format `@expression` and are placed above function
110110
| --------- | ----------- | ------- |
111111
| [description](#description) | string | Provide descriptions for the function. |
112112
| [export](#export) | none | Indicates that the function is available for import by another Bicep file. |
113+
| [metadata](#metadata) | all | object | Custom properties to apply to the function. Can include a description property that is equivalent to the description decorator. |
113114

114115
Decorators are in the [sys namespace](bicep-functions.md#namespaces-for-functions). If you need to differentiate a decorator from another item with the same name, preface the decorator with `sys`. For example, if your Bicep file includes a variable named `description`, you must add the sys namespace when using the **description** decorator.
115116

@@ -128,6 +129,23 @@ Markdown-formatted text can be used for the description text.
128129

129130
Use `@export()` to share the function with other Bicep files. For more information, see [Export variables, types, and functions](./bicep-import.md#export-variables-types-and-functions).
130131

132+
### Metadata
133+
134+
If you have custom properties that you want to apply to a user-defined function, add a metadata decorator. Within the metadata, define an object with the custom names and values. The object you define for the metadata can contain properties of any name and type.
135+
136+
You might use this decorator to track information about the function that doesn't make sense to add to the [description](#description).
137+
138+
```bicep
139+
@description('Configuration values that are applied when the application starts.')
140+
@metadata({
141+
source: 'database'
142+
contact: 'Web team'
143+
})
144+
type settings object
145+
```
146+
147+
When you provide a `@metadata()` decorator with a property that conflicts with another decorator, that decorator always takes precedence over anything in the `@metadata()` decorator. So, the conflicting property within the `@metadata()` value is redundant and will be replaced. For more information, see [No conflicting metadata](./linter-rule-no-conflicting-metadata.md).
148+
131149
## Next steps
132150

133151
* To learn about the Bicep file structure and syntax, see [Understand the structure and syntax of Bicep files](./file.md).

0 commit comments

Comments
 (0)