@@ -5,9 +5,8 @@ services: azure-resource-manager
5
5
author : mumian
6
6
ms.service : azure-resource-manager
7
7
ms.topic : conceptual
8
- ms.date : 10/26 /2022
8
+ ms.date : 11/01 /2022
9
9
ms.author : jgao
10
-
11
10
---
12
11
13
12
# Use deployment scripts in Bicep
@@ -101,7 +100,7 @@ resource runPowerShellInline 'Microsoft.Resources/deploymentScripts@2020-10-01'
101
100
storageAccountName: 'myStorageAccount'
102
101
storageAccountKey: 'myKey'
103
102
}
104
- azPowerShellVersion: '6.4 ' // or azCliVersion: '2.28 .0'
103
+ azPowerShellVersion: '8.3 ' // or azCliVersion: '2.40 .0'
105
104
arguments: '-name \\"John Dole\\"'
106
105
environmentVariables: [
107
106
{
@@ -180,7 +179,7 @@ Property value details:
180
179
181
180
The following Bicep file has one resource defined with the ` Microsoft.Resources/deploymentScripts ` type. The highlighted part is the inline script.
182
181
183
- :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/inlineScript.bicep" range="1-25 " highlight="11-17 ":::
182
+ :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/inlineScript.bicep" range="1-26 " highlight="12-18 ":::
184
183
185
184
The script takes a parameter, and output the parameter value. ` DeploymentScriptOutputs ` is used for storing outputs. The output line shows how to access the stored values. ` Write-Output ` is used for debugging purpose. To learn how to access the output file, see [ Monitor and troubleshoot deployment scripts] ( #monitor-and-troubleshoot-deployment-scripts ) . For the property descriptions, see [ Sample Bicep files] ( #sample-bicep-files ) .
186
185
@@ -207,7 +206,7 @@ You can use the [loadTextContent](bicep-functions-files.md#loadtextcontent) func
207
206
208
207
The following example loads a script from a file and uses it for a deployment script.
209
208
210
- ::: code language="bicep" source="~ /azure-docs-bicep-samples/syntax-samples/functions/loadTextContent/loaddeploymentscript.bicep" highlight="13" :::
209
+ :::code language="bicep" source="~ /azure-docs-bicep-samples/syntax-samples/functions/loadTextContent/loaddeploymentscript.bicep" highlight="13" :::
211
210
212
211
## Use external scripts
213
212
@@ -247,7 +246,7 @@ The supporting files are copied to `azscripts/azscriptinput` at the runtime. Use
247
246
248
247
The following Bicep file shows how to pass values between two ` deploymentScripts ` resources:
249
248
250
- :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/passValues.bicep" range="1-45 " highlight="17-18,33 ":::
249
+ :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/passValues.bicep" range="1-46 " highlight="18-19,34 ":::
251
250
252
251
In the first resource, you define a variable called ` $DeploymentScriptOutputs ` , and use it to store the output values. Use resource symbolic name to access the output values.
253
252
@@ -257,7 +256,7 @@ Different from the PowerShell deployment script, CLI/bash support doesn't expose
257
256
258
257
Deployment script outputs must be saved in the ` AZ_SCRIPTS_OUTPUT_PATH ` location, and the outputs must be a valid JSON string object. The contents of the file must be saved as a key-value pair. For example, an array of strings is stored as ` { "MyResult": [ "foo", "bar"] } ` . Storing just the array results, for example ` [ "foo", "bar" ] ` , is invalid.
259
258
260
- :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/passValue-cli.bicep" range="1-35 " highlight="29 ":::
259
+ :::code language="bicep" source="~ /azure-docs-bicep-samples/samples/deployment-script/passValue-cli.bicep" range="1-36 " highlight="30 ":::
261
260
262
261
[ jq] ( https://stedolan.github.io/jq/ ) is used in the previous sample. It comes with the container images. See [ Configure development environment] ( #configure-development-environment ) .
263
262
@@ -380,10 +379,10 @@ SubscriptionId : 01234567-89AB-CDEF-0123-456789ABCDEF
380
379
ProvisioningState : Succeeded
381
380
Identity : /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/mydentity1008rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myuami
382
381
ScriptKind : AzurePowerShell
383
- AzPowerShellVersion : 3.0
384
- StartTime : 6/18/2020 7:46:45 PM
385
- EndTime : 6/18/2020 7:49:45 PM
386
- ExpirationDate : 6/19/2020 7:49:45 PM
382
+ AzPowerShellVersion : 8.3
383
+ StartTime : 6/18/2022 7:46:45 PM
384
+ EndTime : 6/18/2022 7:49:45 PM
385
+ ExpirationDate : 6/19/2022 7:49:45 PM
387
386
CleanupPreference : OnSuccess
388
387
StorageAccountId : /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0618rg/providers/Microsoft.Storage/storageAccounts/ftnlvo6rlrvo2azscripts
389
388
ContainerInstanceId : /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0618rg/providers/Microsoft.ContainerInstance/containerGroups/ftnlvo6rlrvo2azscripts
@@ -411,13 +410,13 @@ The list command output is similar to:
411
410
[
412
411
{
413
412
"arguments" : " -name \\\" John Dole\\\" " ,
414
- "azPowerShellVersion" : " 3.0 " ,
413
+ "azPowerShellVersion" : " 8.3 " ,
415
414
"cleanupPreference" : " OnSuccess" ,
416
415
"containerSettings" : {
417
416
"containerGroupName" : null
418
417
},
419
418
"environmentVariables" : null ,
420
- "forceUpdateTag" : " 20200625T025902Z " ,
419
+ "forceUpdateTag" : " 20220625T025902Z " ,
421
420
"id" : " /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0624rg/providers/Microsoft.Resources/deploymentScripts/runPowerShellInlineWithOutput" ,
422
421
"identity" : {
423
422
"tenantId" : " 01234567-89AB-CDEF-0123-456789ABCDEF" ,
@@ -442,19 +441,19 @@ The list command output is similar to:
442
441
"scriptContent" : " \r\n param([string] $name)\r\n $output = \" Hello {0}\" -f $name\r\n Write-Output $output\r\n $DeploymentScriptOutputs = @{}\r\n $DeploymentScriptOutputs['text'] = $output\r\n " ,
443
442
"status" : {
444
443
"containerInstanceId" : " /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0624rg/providers/Microsoft.ContainerInstance/containerGroups/64lxews2qfa5uazscripts" ,
445
- "endTime" : " 2020 -06-25T03:00:16.796923+00:00" ,
444
+ "endTime" : " 2022 -06-25T03:00:16.796923+00:00" ,
446
445
"error" : null ,
447
- "expirationTime" : " 2020 -06-26T03:00:16.796923+00:00" ,
448
- "startTime" : " 2020 -06-25T02:59:07.595140+00:00" ,
446
+ "expirationTime" : " 2022 -06-26T03:00:16.796923+00:00" ,
447
+ "startTime" : " 2022 -06-25T02:59:07.595140+00:00" ,
449
448
"storageAccountId" : " /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0624rg/providers/Microsoft.Storage/storageAccounts/64lxews2qfa5uazscripts"
450
449
},
451
450
"storageAccountSettings" : null ,
452
451
"supportingScriptUris" : null ,
453
452
"systemData" : {
454
- "createdAt" : " 2020 -06-25T02:59:04.750195+00:00" ,
453
+ "createdAt" : " 2022 -06-25T02:59:04.750195+00:00" ,
455
454
456
455
"createdByType" : " User" ,
457
- "lastModifiedAt" : " 2020 -06-25T02:59:04.750195+00:00" ,
456
+ "lastModifiedAt" : " 2022 -06-25T02:59:04.750195+00:00" ,
458
457
"lastModifiedBy" :
" [email protected] " ,
459
458
"lastModifiedByType" : " User"
460
459
},
@@ -503,15 +502,15 @@ The output is similar to:
503
502
"systemData" : {
504
503
505
504
"createdByType" : " User" ,
506
- "createdAt" : " 2020 -06-25T02:59:04.7501955Z" ,
505
+ "createdAt" : " 2022 -06-25T02:59:04.7501955Z" ,
507
506
"lastModifiedBy" :
" [email protected] " ,
508
507
"lastModifiedByType" : " User" ,
509
- "lastModifiedAt" : " 2020 -06-25T02:59:04.7501955Z"
508
+ "lastModifiedAt" : " 2022 -06-25T02:59:04.7501955Z"
510
509
},
511
510
"properties" : {
512
511
"provisioningState" : " Succeeded" ,
513
- "forceUpdateTag" : " 20200625T025902Z " ,
514
- "azPowerShellVersion" : " 3.0 " ,
512
+ "forceUpdateTag" : " 20220625T025902Z " ,
513
+ "azPowerShellVersion" : " 8.3 " ,
515
514
"scriptContent" : " \r\n param([string] $name)\r\n $output = \" Hello {0}\" -f $name\r\n Write-Output $output\r\n $DeploymentScriptOutputs = @{}\r\n $DeploymentScriptOutputs['text'] = $output\r\n " ,
516
515
"arguments" : " -name \\\" John Dole\\\" " ,
517
516
"retentionInterval" : " P1D" ,
@@ -520,9 +519,9 @@ The output is similar to:
520
519
"status" : {
521
520
"containerInstanceId" : " /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0624rg/providers/Microsoft.ContainerInstance/containerGroups/64lxews2qfa5uazscripts" ,
522
521
"storageAccountId" : " /subscriptions/01234567-89AB-CDEF-0123-456789ABCDEF/resourceGroups/myds0624rg/providers/Microsoft.Storage/storageAccounts/64lxews2qfa5uazscripts" ,
523
- "startTime" : " 2020 -06-25T02:59:07.5951401Z" ,
524
- "endTime" : " 2020 -06-25T03:00:16.7969234Z" ,
525
- "expirationTime" : " 2020 -06-26T03:00:16.7969234Z"
522
+ "startTime" : " 2022 -06-25T02:59:07.5951401Z" ,
523
+ "endTime" : " 2022 -06-25T03:00:16.7969234Z" ,
524
+ "expirationTime" : " 2022 -06-26T03:00:16.7969234Z"
526
525
},
527
526
"outputs" : {
528
527
"text" : " Hello John Dole"
0 commit comments