0

I can assign the user assigned managed identity manually in the portal.

How do I do it during deployment to a staging slot as part of a deployment pipeline?

I can use PowerShell to set a system assigned managed identity via Set-AzureRMWebAppSlothowever I cannot find a way to do it for User Assigned.

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
GraemeMiller
  • 11,973
  • 8
  • 57
  • 111
  • It is in preview, may be not supported by powershell, you could try to use [ARM template](https://learn.microsoft.com/en-us/azure/app-service/app-service-managed-service-identity#using-an-azure-resource-manager-template-1) to do that. – Joy Wang Dec 17 '18 at 01:06
  • Can I use Arm Template to just update the identity part? We haven't switched over to using Arm Templates to define our environments yet – GraemeMiller Dec 17 '18 at 01:58
  • Yes, you can use it to just update the identity part. – Joy Wang Dec 17 '18 at 02:02
  • 1
    Almost two years later, this still doesn't seem possible. I've filed a feature request: https://github.com/Azure/azure-powershell/issues/13109 – PaulVrugt Sep 29 '20 at 18:41

1 Answers1

2

User-assigned identity is currently in preview, if you want to programmatically assign a User assigned managed identity, you can try to use ARM template to do that.

Sample:

{
    "apiVersion": "2016-08-01",
    "type": "Microsoft.Web/sites",
    "name": "[variables('appName')]",
    "location": "[resourceGroup().location]",
    "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
            "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName'))]": {}
        }
    },
    "properties": {
        "name": "[variables('appName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "hostingEnvironment": "",
        "clientAffinityEnabled": false,
        "alwaysOn": true
    },
    "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName'))]"
    ]
}
Joy Wang
  • 39,905
  • 3
  • 30
  • 54