Skip to content

Commit 1b2b0a5

Browse files
Merge pull request #235456 from danay1999/danay1999/update-bicep-functions-files
Updated bicep-functions-files.md
2 parents e0e6d3d + 9ca6013 commit 1b2b0a5

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

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

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep functions - files
33
description: Describes the functions to use in a Bicep file to load content from a file.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 10/10/2022
6+
ms.date: 04/21/2023
77
---
88

99
# File functions for Bicep
@@ -74,7 +74,49 @@ The following example creates a JSON file that contains values for a network sec
7474

7575
You load that file and convert it to a JSON object. You use the object to assign values to the resource.
7676

77-
::: code language="bicep" source="~/azure-docs-bicep-samples/syntax-samples/functions/loadJsonContent/loadsharedrules.bicep" highlight="3,13-21" :::
77+
::: code language="bicep" source="~/azure-docs-bicep-samples/syntax-samples/functions/loadJsonContent/loadsharedrules.bicep" highlight="3,12" :::
78+
79+
You can reuse the file of values in other Bicep files that deploy a network security group.
80+
81+
## loadYamlContent
82+
83+
`loadYamlContent(filePath, [pathFilter], [encoding])`
84+
85+
Loads the specified YAML file as an Any object.
86+
87+
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
88+
89+
### Parameters
90+
91+
| Parameter | Required | Type | Description |
92+
|:--- |:--- |:--- |:--- |
93+
| filePath | Yes | string | The path to the file to load. The path is relative to the deployed Bicep file. It can't include variables. |
94+
| pathFilter | No | string | The path filter is a JSONPath expression to specify that only part of the file is loaded. |
95+
| encoding | No | string | The file encoding. The default value is `utf-8`. The available options are: `iso-8859-1`, `us-ascii`, `utf-16`, `utf-16BE`, or `utf-8`. |
96+
97+
### Remarks
98+
99+
Use this function when you have YAML content or minified YAML content that is stored in a separate file. Rather than duplicating the YAML content in your Bicep file, load the content with this function. You can load a part of a YAML file by specifying a path filer. The file is loaded when the Bicep file is compiled to the YAML template. You can't include variables in the file path because they haven't been resolved when compiling to the template. During deployment, the YAML template contains the contents of the file as a hard-coded string.
100+
101+
In VS Code, the properties of the loaded object are available intellisense. For example, you can create a file with values to share across many Bicep files. An example is shown in this article.
102+
103+
This function requires **Bicep version >0.16.2**.
104+
105+
The maximum allowed size of the file is **1,048,576 characters**, including line endings.
106+
107+
### Return value
108+
109+
The contents of the file as an Any object.
110+
111+
### Examples
112+
113+
The following example creates a YAML file that contains values for a network security group.
114+
115+
::: code language="yml" source="~/azure-docs-bicep-samples/syntax-samples/functions/loadYamlContent/nsg-security-rules.yaml" :::
116+
117+
You load that file and convert it to a JSON object. You use the object to assign values to the resource.
118+
119+
::: code language="bicep" source="~/azure-docs-bicep-samples/syntax-samples/functions/loadYamlContent/loadsharedrules.bicep" highlight="3,12" :::
78120

79121
You can reuse the file of values in other Bicep files that deploy a network security group.
80122

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep functions
33
description: Describes the functions to use in a Bicep file to retrieve values, work with strings and numerics, and retrieve deployment information.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 07/05/2022
6+
ms.date: 04/21/2023
77
---
88

99
# Bicep functions
@@ -75,6 +75,7 @@ The following functions are available for loading the content from external file
7575

7676
* [loadFileAsBase64](bicep-functions-files.md#loadfileasbase64)
7777
* [loadJsonContent](bicep-functions-files.md#loadjsoncontent)
78+
* [loadYamlContent](bicep-functions-files.md#loadyamlcontent)
7879
* [loadTextContent](bicep-functions-files.md#loadtextcontent)
7980

8081
## Lambda functions

0 commit comments

Comments
 (0)