Skip to content

Commit 3fab807

Browse files
committed
Use interpolation in multi-line strings
1 parent c84f48f commit 3fab807

2 files changed

Lines changed: 20 additions & 34 deletions

File tree

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,11 @@ var storageName = 'storage${uniqueString(resourceGroup().id)}'
355355

356356
### Multi-line strings
357357

358-
In Bicep, multi-line strings are defined between three single quotation marks (`'''`) followed optionally by a newline (the opening sequence) and three single quotation marks (`'''` is the closing sequence). Characters that are entered between the opening and closing sequence are read verbatim. Escaping isn't necessary or possible.
358+
## Multi-line strings
359359

360-
> [!NOTE]
361-
> The Bicep parser reads every character as it is. Depending on the line endings of your Bicep file, newlines are interpreted as either `\r\n` or `\n`.
362-
>
363-
> Interpolation isn't currently supported in multi-line strings. Because of this limitation, you might need to use the [`concat`](./bicep-functions-string.md#concat) function instead of using [interpolation](#strings).
364-
>
365-
> Multi-line strings that contain `'''` aren't supported.
360+
You can define a multi-line string by enclosing it in three single quotation marks (`'''`). The string content is preserved exactly as written, so escape characters are not required. The delimiter `'''` cannot appear within the string.
361+
362+
The string may begin immediately after the opening delimiter or on the following line. In both cases, the resulting value does not include a leading newline. Line breaks are interpreted as `\r\n` or `\n`, depending on the line-ending format of the Bicep file.
366363

367364
```bicep
368365
// evaluates to "hello!"
@@ -396,6 +393,21 @@ var myVar6 = '''interpolation
396393
is ${blocked}'''
397394
```
398395

396+
With Bicep CLI version 0.X.X or higher, string interpolation is supported. An optional `$` prefix can be added before the opening delimiter to enable string interpolation using standard Bicep `${...}` syntax. If you need to include ${...} as a literal value without escaping, you can control interpolation by repeating the `$` prefix. Interpolation is only performed when the number of `$` characters preceding `${...}` matches the number of `$` characters used in the opening delimiter.
397+
398+
```bicep
399+
// evaluates to "this is a test"
400+
var interpolated = 'a test'
401+
var myVar7 = $'''
402+
this is ${interpolated}'''
403+
404+
// evaluates to "this is a testthis is not ${interpolated}"
405+
var interpolated = 'a test'
406+
var myVar8 = $$'''
407+
this is $${interpolated}
408+
this is not ${interpolated}'''
409+
```
410+
399411
### String-related operators
400412

401413
- See [Comparison operators](./operators-comparison.md).

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep file structure and syntax
33
description: Understand how to use declarative syntax to understand the structure and properties of Bicep files.
44
ms.topic: article
55
ms.custom: devx-track-bicep
6-
ms.date: 07/25/2025
6+
ms.date: 01/13/2026
77
---
88

99
# Bicep file structure and syntax
@@ -412,32 +412,6 @@ The following example shows a multiline comment.
412412
param existingKeyVaultName string
413413
```
414414

415-
## Multi-line strings
416-
417-
You can break a string into multiple lines. Use three single quotation marks `'''` to start and end the multi-line string.
418-
419-
Characters within the multi-line string are handled as is. Escape characters are unnecessary. You can't include `'''` in the multi-line string. String interpolation isn't currently supported.
420-
421-
You can start your string right after the opening `'''`, or include a new line. In either case, the resulting string doesn't include a new line. Depending on the line endings in your Bicep file, new lines are interpreted as `\r\n` or `\n`.
422-
423-
The following example shows a multi-line string.
424-
425-
```bicep
426-
var stringVar = '''
427-
this is multi-line
428-
string with formatting
429-
preserved.
430-
'''
431-
```
432-
433-
The preceding example is equivalent to the following JSON:
434-
435-
```json
436-
"variables": {
437-
"stringVar": "this is multi-line\r\n string with formatting\r\n preserved.\r\n"
438-
}
439-
```
440-
441415
## Multiple-line declarations
442416

443417
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).

0 commit comments

Comments
 (0)