You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/bicep-functions-parameters-file.md
+53-1Lines changed: 53 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Bicep functions - parameters file
3
-
description: Describes the functions used in the Bicep parameters files.
3
+
description: This article describes the Bicep functions to be used in Bicep parameter files.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-bicep
6
6
ms.date: 06/05/2023
@@ -10,6 +10,58 @@ ms.date: 06/05/2023
10
10
11
11
Bicep provides a function called `readEnvironmentVariable()` that allows you to retrieve values from environment variables. It also offers the flexibility to set a default value if the environment variable does not exist. This function can only be used in the `.bicepparam` files. For more information, see [Bicep parameters file](./parameter-files.md).
Returns a secret from an [Azure Key Vault](../../key-vault/secrets/about-secrets.md). Use this function to pass a secret to a secure string parameter of a Bicep file.
18
+
19
+
> [!NOTE]
20
+
> You can also use the [keyVaultName.getSecret(secretName)](./bicep-functions-resource.md#getsecret) function from within a `.bicep` file.
You'll get an error if you use this function with string interpolation.
30
+
31
+
A [namespace qualifier](bicep-functions.md#namespaces-for-functions) (`az`) can be used, but it's optional, because the function is available from the _default_ Azure Namespace.
32
+
33
+
### Parameters
34
+
35
+
| Parameter | Required | Type | Description |
36
+
|:--- |:--- |:--- |:--- |
37
+
| subscriptionId | Yes | string | The ID of the subscription that has the key vault resource. |
38
+
| resourceGroupName | Yes | string | The name of the resource group that has the key vault resource. |
39
+
| keyVaultName | Yes | string | The name of the key vault. |
40
+
| secretName | Yes | string | The name of the secret stored in the key vault. |
41
+
| secretVersion | No | string | The version of the secret stored in the key vault. |
42
+
43
+
### Return value
44
+
45
+
The value for the secret.
46
+
47
+
### Example
48
+
49
+
The following `.bicepparam` file has a `securePassword` parameter that will have the latest value of the _\<secretName\>_ secret.
The following `.bicepparam` file has a `securePassword` parameter that will have the value of the _\<secretName\>_ secret, but it's pinned to a specific _\<secretValue\>_.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/bicep-functions-resource.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,9 @@ Built-in policy definitions are tenant level resources. For an example of deploy
106
106
107
107
Returns a secret from an Azure Key Vault. Use this function to pass a secret to a secure string parameter of a Bicep module.
108
108
109
+
> [!NOTE]
110
+
> `az.getSecret(subscriptionId, resourceGroupName, keyVaultName, secretName, secretVersion)` function can be used in `.bicepparam` files to retrieve key vault secrets. For more information, see [getSecret](./bicep-functions-parameters-file.md#getsecret).
111
+
109
112
You can only use the `getSecret` function from within the `params` section of a module. You can only use it with a `Microsoft.KeyVault/vaults` resource.
110
113
111
114
```bicep
@@ -117,7 +120,7 @@ module sql './sql.bicep' = {
117
120
}
118
121
```
119
122
120
-
You'll get an error if you attempt to use this function in any other part of the Bicep file. You'll also get an error if you use this function with string interpolation, even when used in the params section.
123
+
You get an error if you attempt to use this function in any other part of the Bicep file. You also get an error if you use this function with string interpolation, even when used in the params section.
121
124
122
125
The function can be used only with a module parameter that has the `@secure()` decorator.
123
126
@@ -137,7 +140,7 @@ The secret value for the secret name.
137
140
138
141
### Example
139
142
140
-
The following Bicep file is used as a module. It has an `adminPassword` parameter defined with the `@secure()` decorator.
143
+
The following Bicep file is used as a module. It has an `adminPassword` parameter defined with the `@secure()` decorator.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/bicep-functions.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,6 +123,8 @@ The following functions are available for working with objects. All of these fun
123
123
124
124
## Parameters file functions
125
125
126
+
The [getSecret function](./bicep-functions-parameters-file.md) is available in Bicep to get secure value from a KeyVault. This function is in the `az` namespace.
127
+
126
128
The [readEnvironmentVariable function](./bicep-functions-parameters-file.md) is available in Bicep to read environment variable values. This function is in the `sys` namespace.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/key-vault-parameter.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,15 @@ module sql './sql.bicep' = {
202
202
}
203
203
```
204
204
205
+
Also, `getSecret` function (or with the namespace qualifier `az.getSecret`) can be used in a `.bicepparam` file to retrieve the value of a secret from a key vault.
If you don't want to use a module, you can reference the key vault directly in the parameters file. The following image shows how the parameters file references the secret and passes that value to the Bicep file.
When you use `.bicepparam` file format, you can provide secure values to parameters by using [the `getSecret` function](bicep-functions-parameters-file.md#getsecret).
86
+
87
+
Reference the KeyVault by providing the subscription ID, resource group name, and key vault name. You can get the value of the secret by providing the secret name. You can optionally provide the secret version. If you don't provide the secret version, the latest version is used.
0 commit comments