Skip to content

Commit e7a39fc

Browse files
Merge pull request #290827 from mumian/1112-spread
Improve the spread function article.
2 parents 8294090 + 5279287 commit e7a39fc

File tree

3 files changed

+69
-15
lines changed

3 files changed

+69
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The following functions are available for working with lambda expressions. All o
9898
* [sort](bicep-functions-lambda.md#sort)
9999
* [toObject](bicep-functions-lambda.md#toobject)
100100

101-
## Logical functions
101+
## Logical function
102102

103103
The following function is available for working with logical conditions. This function is in the `sys` namespace.
104104

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

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@ title: Data types in Bicep
33
description: This article describes the data types that are available in Bicep.
44
ms.topic: reference
55
ms.custom: devx-track-bicep
6-
ms.date: 08/20/2024
6+
ms.date: 11/12/2024
77
---
88

99
# Data types in Bicep
1010

1111
This article describes the data types that are supported in [Bicep](./overview.md). To define custom data types, see [User-defined data types](./user-defined-data-types.md).
1212

13-
## Supported types
14-
15-
Within Bicep, you can use these data types:
16-
17-
* [array](#arrays)
18-
* [bool](#booleans)
19-
* [int](#integers)
20-
* [object](#objects)
21-
* [secureObject (indicated by a decorator in Bicep](#secure-strings-and-objects))
22-
* [secureString (indicated by a decorator in Bicep](#secure-strings-and-objects))
23-
* [string](#strings)
24-
2513
## Arrays
2614

2715
Arrays start with a left bracket (`[`) and end with a right bracket (`]`). In Bicep, you can declare an array in a single line or in multiple lines. Commas (`,`) are used between values in single-line declarations, but they aren't used in multiple-line declarations. You can mix and match single-line and multiple-line declarations. The multiple-line declaration requires [Bicep CLI version 0.7.X or higher](./install.md).
@@ -86,6 +74,18 @@ output foo bool = empty(emptyArray) || emptyArray[0] == 'bar'
8674
output bar bool = length(numberArray) <= 3 || numberArray[3] == 4
8775
```
8876

77+
### Array-related operators
78+
79+
* Use [Comparison operators](./operators-comparison.md) to compare two arrays.
80+
* Use [Index accessor](./operators-access.md#index-accessor) to get an element from an array.
81+
* Use [Safe-dereference operator](./operator-safe-dereference.md) to access elements of an array.
82+
* Use [Spread](./operator-spread.md) to merge arrays.
83+
84+
### Array-related functions
85+
86+
* See [Array functions](./bicep-functions-array.md).
87+
* See [Lambda functions](./bicep-functions-lambda.md).
88+
8989
## Booleans
9090

9191
When you specify Boolean values, use `true` or `false`. Don't surround the value with quotation marks.
@@ -94,6 +94,15 @@ When you specify Boolean values, use `true` or `false`. Don't surround the value
9494
param exampleBool bool = true
9595
```
9696

97+
## Boolean-related operators
98+
99+
* Use [Comparison operators](./operators-comparison.md) to compare boolean values.
100+
* See [Logical operators](./operators-logical.md).
101+
102+
## Boolean-related functions
103+
104+
See [Logical function](./bicep-functions-logical.md)
105+
97106
## Integers
98107

99108
When you specify integer values, don't use quotation marks.
@@ -129,6 +138,15 @@ output bar 1 | 2 | 3 = 3
129138

130139
Floating point, decimal, or binary formats aren't currently supported.
131140

141+
### Integer-related operators
142+
143+
* See [Comparison operators](./operators-comparison.md).
144+
* See [Numeric operators](./operators-numeric.md).
145+
146+
### Integer-related functions
147+
148+
See [Numeric functions](./bicep-functions-numeric.md).
149+
132150
## Objects
133151

134152
Objects start with a left brace (`{`) and end with a right brace (`}`). In Bicep, you can declare an object in a single line or in multiple lines. Each property in an object consists of a key and a value. The key and value are separated by a colon (`:`). An object allows any property of any type. Commas (`,`) are used between properties for single-line declarations, but they aren't used between properties for multiple-line declarations. You can mix and match single-line and multiple-line declarations. The multiple-line declaration requires [Bicep CLI version 0.7.X or higher](./install.md).
@@ -217,6 +235,17 @@ param objectToTest object = {
217235
output bar bool = contains(objectToTest, 'four') && objectToTest.four == 4
218236
```
219237

238+
### Object-related operators
239+
240+
* Use [Comparison operators](./operators-comparison.md) to compare objects.
241+
* Use [Index accessor](./operators-access.md#index-accessor) to get a property from an object.
242+
* Use [Safe-dereference operator](./operator-safe-dereference.md) to access object members.
243+
* Use [Spread](./operator-spread.md) to merge objects.
244+
245+
### Object-related functions
246+
247+
See [Object functions](./bicep-functions-object.md).
248+
220249
## Strings
221250

222251
In Bicep, strings are marked with single quotation marks, and you must declare them on a single line. All Unicode characters with code points between `0` and `10FFFF` are allowed.
@@ -317,6 +346,13 @@ var myVar6 = '''interpolation
317346
is ${blocked}'''
318347
```
319348

349+
### String-related operators
350+
351+
* See [Comparison operators](./operators-comparison.md).
352+
353+
### String-related functions
354+
355+
320356
## Union types
321357

322358
In Bicep, a union type allows the creation of a combined type that consists of a set of subtypes. An assignment is valid if any of the individual subtype assignments are permitted. The `|` character separates individual subtypes that use 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.

articles/azure-resource-manager/bicep/operator-spread.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep spread operator
33
description: Describes Bicep spread operator.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 08/07/2024
6+
ms.date: 11/20/2024
77
---
88

99
# Bicep spread operator
@@ -74,6 +74,24 @@ In this usage, comma isn't used between the two lines. Output from the example:
7474
|------|------|-------|
7575
| `objCombined` | object | { color: 'white', shape: 'circle' } |
7676

77+
The following example shows how to conditionally add an array element:
78+
79+
```bicep
80+
@allowed(['white', 'black'])
81+
param color string = 'black'
82+
83+
var colorWhite = { color: 'white' }
84+
var colorBlack = { color: 'black' }
85+
86+
output objB object = ((color == 'white')? { shape: 'circle', ...colorWhite} : { shape: 'circle', ...colorBlack})
87+
```
88+
89+
Output from the example:
90+
91+
| Name | Type | Value |
92+
|------|------|-------|
93+
| `objB` | object | { shape: 'circle', color: 'black' } |
94+
7795
The spread operation can be used to avoid setting an optional property. In the following example, _accessTier_ is set only if the parameter _tier_ isn't an empty string.
7896

7997
```bicep

0 commit comments

Comments
 (0)