Skip to content

Commit d40196c

Browse files
Merge pull request #310438 from mumian/0113-interpolation
Use interpolation in multi-line strings
2 parents 51ed514 + 3bfe5fc commit d40196c

3 files changed

Lines changed: 23 additions & 37 deletions

File tree

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Data types in Bicep
33
description: This article describes the data types that are available in Bicep.
44
ms.topic: reference
5-
ms.date: 01/02/2026
5+
ms.date: 01/27/2026
66
ms.custom: devx-track-bicep
77
---
88

@@ -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!"
@@ -389,11 +386,26 @@ var myVar5 = '''
389386
comments // are included
390387
/* because everything is read as-is */
391388
'''
389+
```
390+
391+
With Bicep CLI version v0.40.2 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.
392392

393+
```bicep
393394
// evaluates to "interpolation\nis ${blocked}"
394395
// note ${blocked} is part of the string, and is not evaluated as an expression
395396
var myVar6 = '''interpolation
396397
is ${blocked}'''
398+
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 test\nthis is not ${interpolated}"
405+
var interpolated = 'a test'
406+
var myVar8 = $$'''
407+
this is $${interpolated}
408+
this is not ${interpolated}'''
397409
```
398410

399411
### String-related operators

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
@@ -464,32 +464,6 @@ The following example shows a multiline comment.
464464
param existingKeyVaultName string
465465
```
466466

467-
## Multi-line strings
468-
469-
You can break a string into multiple lines. Use three single quotation marks `'''` to start and end the multi-line string.
470-
471-
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.
472-
473-
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`.
474-
475-
The following example shows a multi-line string.
476-
477-
```bicep
478-
var stringVar = '''
479-
this is multi-line
480-
string with formatting
481-
preserved.
482-
'''
483-
```
484-
485-
The preceding example is equivalent to the following JSON:
486-
487-
```json
488-
"variables": {
489-
"stringVar": "this is multi-line\r\n string with formatting\r\n preserved.\r\n"
490-
}
491-
```
492-
493467
## Multiple-line declarations
494468

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

articles/azure-resource-manager/templates/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template structure and syntax
33
description: Describes the structure and properties of Azure Resource Manager templates (ARM templates) using declarative JSON syntax.
44
ms.topic: article
55
ms.custom: devx-track-arm-template
6-
ms.date: 04/28/2025
6+
ms.date: 01/13/2026
77
---
88

99
# Understand the structure and syntax of ARM templates
@@ -497,7 +497,7 @@ You can break a string into multiple lines. For example, see the `location` prop
497497
],
498498
```
499499

500-
In Bicep, see [multi-line strings](../bicep/file.md#multi-line-strings).
500+
In Bicep, see [multi-line strings](../bicep/data-types.md#multi-line-strings).
501501

502502
## languageVersion 2.0
503503

0 commit comments

Comments
 (0)