Skip to content

Commit 6dcd749

Browse files
committed
edit
1 parent 41d1c8a commit 6dcd749

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

articles/azure-resource-manager/bicep/key-vault-parameter.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ The following procedure shows how to create a role with the minimum permission,
151151

152152
When using a key vault with the Bicep file for a [Managed Application](../managed-applications/overview.md), you must grant access to the **Appliance Resource Provider** service principal. For more information, see [Access Key Vault secret when deploying Azure Managed Applications](../managed-applications/key-vault-access.md).
153153

154-
## Reference secrets in Bicep file
154+
## Retrieve secrets in Bicep file
155155

156-
You can use the [getSecret function](./bicep-functions-resource.md#getsecret) in .bicep files to obtain a key vault secret. Note that the `getSecret` function is exclusively applicable to a `Microsoft.KeyVault/vaults` resource. Additionally, it's restricted to usage within the `params` section of a module and can only be used with parameters with the `@secure()` decorator.
156+
You can use the [getSecret function](./bicep-functions-resource.md#getsecret) in Bicep files to obtain a key vault secret. Note that the `getSecret` function is exclusively applicable to a `Microsoft.KeyVault/vaults` resource. Additionally, it's restricted to usage within the `params` section of a module and can only be used with parameters with the `@secure()` decorator.
157157

158-
Another function called `az.getSecret()` function can be used in .bicepparam files to retrieve key vault secrets. For more information, see [Reference secrets in parameters file](#reference-secrets-in-parameters-file).
158+
Another function called `az.getSecret()` function can be used in Bicep parameter files to retrieve key vault secrets. For more information, see [Reference secrets in parameters file](#reference-secrets-in-parameters-file).
159159

160-
The following Bicep file creates an Azure SQL server. The `adminPassword` parameter has a `@secure()` decorator.
160+
Because the `getSecret` function can only be used in the `params` section of a module. Let's create a *sql.bicep* in the same directory as the *main.bicep* file with the following content:
161161

162162
```bicep
163163
param sqlServerName string
@@ -167,7 +167,7 @@ param adminLogin string
167167
@secure()
168168
param adminPassword string
169169

170-
resource sqlServer 'Microsoft.Sql/servers@2020-11-01-preview' = {
170+
resource sqlServer 'Microsoft.Sql/servers@2023-08-01-preview' = {
171171
name: sqlServerName
172172
location: location
173173
properties: {
@@ -178,7 +178,7 @@ resource sqlServer 'Microsoft.Sql/servers@2020-11-01-preview' = {
178178
}
179179
```
180180

181-
Let's use the preceding Bicep file as a module given the file name is *sql.bicep* in the same directory as the main Bicep file.
181+
Notice in the preceding Bicep file, the `adminPassword` parameter has a `@secure()` decorator.
182182

183183
The following Bicep file consumes the *sql.bicep* as a module. The Bicep file references an existing key vault, and calls the `getSecret` function to retrieve the key vault secret, and then passes the value as a parameter to the module.
184184

@@ -190,7 +190,7 @@ param subscriptionId string
190190
param kvResourceGroup string
191191
param kvName string
192192
193-
resource kv 'Microsoft.KeyVault/vaults@2023-02-01' existing = {
193+
resource kv 'Microsoft.KeyVault/vaults@2023-07-01' existing = {
194194
name: kvName
195195
scope: resourceGroup(subscriptionId, kvResourceGroup )
196196
}
@@ -205,9 +205,9 @@ module sql './sql.bicep' = {
205205
}
206206
```
207207

208-
## Reference secrets in parameters file
208+
## Retrieve secrets in parameters file
209209

210-
If you don't want to use a module, you can reference the key vault in the parameters file. However, the approach varies depending on whether you're using a JSON parameter file or a Bicep parameter file.
210+
If you don't want to use a module, you can retrieve key vault secrets in parameters file. However, the approach varies depending on whether you're using a JSON parameter file or a Bicep parameter file.
211211

212212
The following Bicep file deploys a SQL server that includes an administrator password. The password parameter is set to a secure string. But the Bicep doesn't specify where that value comes from.
213213

@@ -219,7 +219,7 @@ param adminLogin string
219219
@secure()
220220
param adminPassword string
221221
222-
resource sqlServer 'Microsoft.Sql/servers@2022-11-01-preview' = {
222+
resource sqlServer 'Microsoft.Sql/servers@2023-08-01-preview' = {
223223
name: sqlServerName
224224
location: location
225225
properties: {
@@ -240,7 +240,7 @@ Now, create a parameters file for the preceding Bicep file.
240240
using './main.bicep'
241241
242242
param sqlServerName = '<your-server-name>'
243-
param adminLogin = '<your-admin-login'
243+
param adminLogin = '<your-admin-login>'
244244
param adminPassword = az.getSecret('<subscription-id>', '<rg-name>', '<key-vault-name>', '<secret-name>', '<secret-version>')
245245
```
246246

0 commit comments

Comments
 (0)