-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deployment script example with no managed identity (#1006)
* deployment script example with no identity * fix tests * add readme * update readme * fix formatting
- Loading branch information
1 parent
ce5add5
commit a0f0d4e
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Deployment Script with no managed identity | ||
|
||
As of apiVersion `2020-10-01`, the `identity` is optional. The permissions of the principal creating the template deployment will be used to provision the ACI and/or storage resources that are required for the script to execute. | ||
|
||
Note that if a managed identity is not provided, there will be **no preconfigured authentication to Az powershell or Az CLI** in this case. If you need to reach Azure, we recommend adding a managed identity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
param location string = 'westus' | ||
param timestamp string = utcNow() | ||
param dsName string = 'ds${uniqueString(resourceGroup().name)}' | ||
|
||
resource script 'Microsoft.Resources/deploymentScripts@2020-10-01' = { | ||
kind: 'AzurePowerShell' | ||
name: dsName | ||
location: location | ||
// identity property no longer required | ||
properties: { | ||
azPowerShellVersion: '3.0' | ||
scriptContent: '$DeploymentScriptOutputs["test"] = "test this output"' | ||
forceUpdateTag: timestamp // script will run every time | ||
retentionInterval: 'PT4H' // deploymentScript resource will delete itself in 4 hours | ||
} | ||
} | ||
|
||
output scriptOutput string = script.properties.outputs.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "westus" | ||
}, | ||
"timestamp": { | ||
"type": "string", | ||
"defaultValue": "[utcNow()]" | ||
}, | ||
"dsName": { | ||
"type": "string", | ||
"defaultValue": "[format('ds{0}', uniqueString(resourceGroup().name))]" | ||
} | ||
}, | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Resources/deploymentScripts", | ||
"apiVersion": "2020-10-01", | ||
"kind": "AzurePowerShell", | ||
"name": "[parameters('dsName')]", | ||
"location": "[parameters('location')]", | ||
"properties": { | ||
"azPowerShellVersion": "3.0", | ||
"scriptContent": "$DeploymentScriptOutputs[\"test\"] = \"test this output\"", | ||
"forceUpdateTag": "[parameters('timestamp')]", | ||
"retentionInterval": "PT4H" | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"scriptOutput": { | ||
"type": "string", | ||
"value": "[reference(resourceId('Microsoft.Resources/deploymentScripts', parameters('dsName'))).outputs.test]" | ||
} | ||
} | ||
} |