Skip to content

Commit fe7b78c

Browse files
committed
improve decorators
1 parent fca5b02 commit fe7b78c

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Bicep file structure and syntax
33
description: Describes the structure and properties of a Bicep file using declarative syntax.
44
ms.topic: conceptual
5-
ms.date: 09/30/2021
5+
ms.date: 10/01/2021
66
---
77

88
# Understand the structure and syntax of Bicep files
@@ -179,6 +179,8 @@ param name string
179179
param description string
180180
```
181181

182+
For more information, see [Decorators](parameters.md#decorators).
183+
182184
## Variables
183185

184186
Use variables for complex expressions that are repeated in a Bicep file. For example, you might add a variable for a resource name that is constructed by concatenating several values together.

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Describes how to define parameters in a Bicep file.
44
author: mumian
55
ms.author: jgao
66
ms.topic: conceptual
7-
ms.date: 09/30/2021
7+
ms.date: 10/01/2021
88
---
99

1010
# Parameters in Bicep
@@ -51,7 +51,17 @@ You can use another parameter value to build a default value. The following temp
5151

5252
## Decorators
5353

54-
Parameters use decorators for constraints or metadata. The decorators are in the format `@expression` and are placed above the parameter's declaration. You can mark a parameter as secure, specify allowed values, set the minimum and maximum length for a string, set the minimum and maximum value for an integer, and provide a description of the parameter. The following sections show how to use these decorators.
54+
Parameters use decorators for constraints or metadata. The decorators are in the format `@expression` and are placed above the parameter's declaration. You can mark a parameter as secure, specify allowed values, set the minimum and maximum length for a string, set the minimum and maximum value for an integer, and provide a description of the parameter.
55+
56+
The following example shows two common uses for decorators.
57+
58+
```bicep
59+
@secure()
60+
param demoPassword string
61+
62+
@description('Must be at least Standard_A3 to support 2 NICs.')
63+
param virtualMachineSize string = 'Standard_DS1_v2'
64+
```
5565

5666
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 parameter named `description`, you must add the sys namespace when using the **description** decorator.
5767

@@ -62,7 +72,9 @@ param name string
6272
param description string
6373
```
6474

65-
## Secure parameters
75+
The available decorators are described in the following sections.
76+
77+
### Secure parameters
6678

6779
You can mark string or object parameters as secure. The value of a secure parameter isn't saved to the deployment history and isn't logged.
6880

@@ -74,7 +86,7 @@ param demoPassword string
7486
param demoSecretObject object
7587
```
7688

77-
## Allowed values
89+
### Allowed values
7890

7991
You can define allowed values for a parameter. You provide the allowed values in an array. The deployment fails during validation if a value is passed in for the parameter that isn't one of the allowed values.
8092

@@ -86,7 +98,7 @@ You can define allowed values for a parameter. You provide the allowed values in
8698
param demoEnum string
8799
```
88100

89-
## Length constraints
101+
### Length constraints
90102

91103
You can specify minimum and maximum lengths for string and array parameters. 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.
92104

@@ -102,7 +114,7 @@ param storageAccountName string
102114
param appNames array
103115
```
104116

105-
## Integer constraints
117+
### Integer constraints
106118

107119
You can set minimum and maximum values for integer parameters. You can set one or both constraints.
108120

@@ -112,7 +124,7 @@ You can set minimum and maximum values for integer parameters. You can set one o
112124
param month int
113125
```
114126

115-
## Description
127+
### Description
116128

117129
To help users understand the value to provide, add a description to the parameter. When deploying the template through the portal, the description's text is automatically used as a tip for that parameter. Only add a description when the text provides more information than can be inferred from the parameter name.
118130

0 commit comments

Comments
 (0)