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/templates/deployment-script-template.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ The benefits of deployment script:
72
72
73
73
-**Azure PowerShell version 3.0.0, 2.8.0 or 2.7.0** or **Azure CLI version 2.0.80, 2.0.79, 2.0.78 or 2.0.77**. You don't need these versions for deploying templates. But these versions are needed for testing deployment scripts locally. See [Install the Azure PowerShell module](/powershell/azure/install-az-ps). You can use a preconfigured Docker image. See [Configure development environment](#configure-development-environment).
74
74
75
-
## Sample template
75
+
## Sample templates
76
76
77
77
The following json is an example. The latest template schema can be found [here](/azure/templates/microsoft.resources/deploymentscripts).
78
78
@@ -125,6 +125,15 @@ Property value details:
125
125
-**cleanupPreference**. Specify the preference of cleaning up deployment resources when the script execution gets in a terminal state. Default setting is **Always**, which means deleting the resources despite the terminal state (Succeeded, Failed, Canceled). To learn more, see [Clean up deployment script resources](#clean-up-deployment-script-resources).
126
126
-**retentionInterval**: Specify the interval for which the service retains the deployment script resources after the deployment script execution reaches a terminal state. The deployment script resources will be deleted when this duration expires. Duration is based on the [ISO 8601 pattern](https://en.wikipedia.org/wiki/ISO_8601). The default value is **P1D**, which means seven days. This property is used when cleanupPreference is set to *OnExpiration*. The *OnExpiration* property is not enabled currently. To learn more, see [Clean up deployment script resources](#clean-up-deployment-script-resources).
127
127
128
+
### Additional samples
129
+
130
+
-[create and assign a certificate to a key vault](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/deployment-script/deploymentscript-keyvault.json)
131
+
132
+
-[create and assign a user-assigned managed identity to a resource group, and run a deployment script](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/deployment-script/deploymentscript-keyvault-mi.json).
133
+
134
+
> [!NOTE]
135
+
> It is recommended to create a user-assigned identity and grant permissions in advance. You might get sign-in and permission related errors if you create the identity and grant permissions in the same template where you run deployment scripts. It takes some time before the permissions to become effective.
136
+
128
137
## Use inline scripts
129
138
130
139
The following template has one resource defined with the `Microsoft.Resources/deploymentScripts` type.
@@ -134,7 +143,7 @@ The following template has one resource defined with the `Microsoft.Resources/de
134
143
> [!NOTE]
135
144
> Because the inline deployment scripts are enclosed in double quotes, the strings inside the deployment scripts need to be enclosed in single quotes instead. The escape character for PowerShell is **\**. You can also consider using string substitution as it is shown in the previous JSON sample. See the default value of the name parameter.
136
145
137
-
The script takes one parameter, and output the parameter value. **DeploymentScriptOutputs** is used for storing outputs. In the outputs section, the **value** line shows how to access the stored values. `Write-Output` is used for debugging purpose. To learn how to access the output file, see [Debug deployment scripts](#debug-deployment-scripts). For the property descriptions, see [Sample template](#sample-template).
146
+
The script takes one parameter, and output the parameter value. **DeploymentScriptOutputs** is used for storing outputs. In the outputs section, the **value** line shows how to access the stored values. `Write-Output` is used for debugging purpose. To learn how to access the output file, see [Debug deployment scripts](#debug-deployment-scripts). For the property descriptions, see [Sample templates](#sample-templates).
138
147
139
148
To run the script, select **Try it** to open Azure Cloud Shell, and then paste the following code into the shell pane.
140
149
@@ -213,7 +222,6 @@ Deployment script outputs must be saved in the AZ_SCRIPTS_OUTPUT_PATH location,
213
222
You can control how PowerShell responds to non-terminating errors by using the [**$ErrorActionPreference**](/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7#erroractionpreference
214
223
) variable in your deployment script. The deployment script engine doesn't set/change the value. Despite the value you set for $ErrorActionPreference, deployment script sets the resource provisioning state to *Failed* when the script encounters an error.
215
224
216
-
217
225
## Debug deployment scripts
218
226
219
227
The script service creates a [storage account](../../storage/common/storage-account-overview.md) and a [container instance](../../container-instances/container-instances-overview.md) for script execution. Both resources have the **azscripts** suffix in the resource names.
0 commit comments