Skip to content

Commit 73cf06b

Browse files
authored
Merge pull request #105497 from mumian/0224-ds-mi
add a mi template sample
2 parents 0bf614b + 43d26f4 commit 73cf06b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

articles/azure-resource-manager/templates/deployment-script-template.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The benefits of deployment script:
7272

7373
- **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).
7474

75-
## Sample template
75+
## Sample templates
7676

7777
The following json is an example. The latest template schema can be found [here](/azure/templates/microsoft.resources/deploymentscripts).
7878

@@ -125,6 +125,15 @@ Property value details:
125125
- **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).
126126
- **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).
127127

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+
128137
## Use inline scripts
129138

130139
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
134143
> [!NOTE]
135144
> 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.
136145
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).
138147

139148
To run the script, select **Try it** to open Azure Cloud Shell, and then paste the following code into the shell pane.
140149

@@ -213,7 +222,6 @@ Deployment script outputs must be saved in the AZ_SCRIPTS_OUTPUT_PATH location,
213222
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
214223
) 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.
215224

216-
217225
## Debug deployment scripts
218226

219227
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

Comments
 (0)