Skip to content

Commit

Permalink
pol assign inline add
Browse files Browse the repository at this point in the history
  • Loading branch information
kramit committed Mar 29, 2020
1 parent 4a2941b commit 1fc723e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions templates/policytestvm/az104-04-vms-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"policyDefinitionName": {
"type": "string",
"metadata": {
"displayName": "Policy definition name",
"description": "Name of the policy to assign."
},
"defaultValue": "vmrestriction"

},
"rgName": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
Expand Down Expand Up @@ -235,8 +244,9 @@
"apiVersion": "2018-05-01",
"name": "vmrestriction",
"properties": {
"scope": "[subscription().id]",
"policyDefinitionId": "[resourceId('Microsoft.Authorization/policyDefinitions', 'vmrestriction')]"
"scope": "[if(empty(parameters('rgName')), subscription().id, concat(subscription().id, '/resourceGroups/', parameters('rgName')))]",
"enforcementMode": "Default",
"policyDefinitionId": "[concat(subscription().id, '/providers/Microsoft.Authorization/policyDefinitions/', parameters('policyDefinitionName'))]"
}
}
],
Expand Down

0 comments on commit 1fc723e

Please sign in to comment.