Last active
September 9, 2020 08:24
-
-
Save NickDarvey/2957bfd7f0b5e79e1993e0cc5d653b30 to your computer and use it in GitHub Desktop.
Deploy an Azure Role Assignment to grant a User-Assigned Managed Identity access to Storage Account
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
// Based on https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-template#resource-scope | |
[ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2019-06-01", | |
"name": "[variables('myStorageAccountName')]", | |
"location": "[variables('location')]", | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"properties": { | |
"supportsHttpsTrafficOnly": true | |
} | |
}, | |
{ | |
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments", | |
"apiVersion": "2018-09-01-preview", | |
"name": "[concat(variables('myStorageAccountName'), '/Microsoft.Authorization/', guid(uniqueString(variables('myStorageAccountName'))))]", | |
"properties": { | |
"_comment1": "Role definition IDs from: https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#storage", | |
"roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]", | |
"_comment2": "Something like: /subscriptions/my-subscription/resourceGroups/my-other-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myManagedIdentity", | |
"principalId": "[reference(parameters('myManagedIdentity'), '2018-11-30').principalId]" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Storage/storageAccounts/', variables('myStorageAccountName'))]" | |
] | |
}, | |
{ | |
"type": "Microsoft.Web/sites", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('myWebSiteName')]", | |
"location": "[variables('location')]", | |
"identity": { | |
"type": "UserAssigned", | |
"userAssignedIdentities": { | |
"[parameters('myManagedIdentity')]": { } | |
} | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Web/serverfarms/', variables('myServerFarmName'))]", | |
"[concat('Microsoft.Storage/storageAccounts/', variables('myStorageAccount'))]" | |
], | |
"properties": { | |
"name": "[variables('myWebSiteName')]", | |
"serverFarmId": "[resourceId('Microsoft.Web/serverFarms',variables('myServerFarmName'))]" | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment