Skip to content

Commit

Permalink
deployment script example with no managed identity (#1006)
Browse files Browse the repository at this point in the history
* deployment script example with no identity

* fix tests

* add readme

* update readme

* fix formatting
  • Loading branch information
alex-frankel authored Nov 25, 2020
1 parent ce5add5 commit a0f0d4e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/examples/101/deployment-script-no-auth/README.md
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.
18 changes: 18 additions & 0 deletions docs/examples/101/deployment-script-no-auth/main.bicep
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
40 changes: 40 additions & 0 deletions docs/examples/101/deployment-script-no-auth/main.json
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]"
}
}
}

0 comments on commit a0f0d4e

Please sign in to comment.