Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.02k stars 16.11k forks source link

Web App Deployment Slot doesn't turn on System Assigned Identity #7764

Open glennsaint-86 opened 4 years ago

glennsaint-86 commented 4 years ago

Deploy a Web App with custom deployment slots

Issue Details

When "clonningInfo" is specified in the properties, it won't create a system assigned identity even it is specified in the template. This only happens if clonningInfo is specified. Below is the template snippet:

{
  "type": "Microsoft.Web/sites/slots",
  "apiVersion": "2018-11-01",
  "name": "[concat(parameters('name'), '/', parameters('deploymentSlots')[copyIndex()])]",
  "kind": "app",
  "location": "[parameters('location')]",
  "identity": {
     "type": "SystemAssigned"
   },
   "comments": "This specifies the web app slots.",
   "tags": "[parameters('commonResourceTags')]",
   "properties": {
      "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
      "cloningInfo": {
       "sourceWebAppId": "[resourceId('Microsoft.Web/Sites/', parameters('name'))]"
       }
    },
   "dependsOn": [
       "[resourceId('Microsoft.Web/Sites', parameters('name'))]"
    ],
    "copy": {
       "name": "copySlots",
    "count": "[length(parameters('deploymentSlots'))]"
    } 
}

Repro steps (if necessary, delete otherwise)

  1. Create an app service azure resource with deployment slot that clones the information to the deployment slot and at the same time assign an SystemAssigned identity
MCKLMT commented 4 years ago

Can you share a complete template demonstrating the issue to be able to reproduce it quickly please?

theonesuperdave commented 4 years ago

I see the same issue for me as well, when using the cloningInfo object. The original lists the quick start sample here which is very similar to what I am using as well; my usage simply does not not use the copy directive as I only have one deployment slot.

For me, the slot resource is created an all of the proper values cloned; there is simply no SystemAssigned Managed Identity. Rather, that "status" shows as "Off".

I should also note that manually creating a SystemAssigned MI for the slot through the Azure Portal works just fine. It also works just fine using Az.Websites posh after the ARM template creates the resource. Why does it not work in the ARM template?

Any ideas, @MCKLMT?

MCKLMT commented 4 years ago

I was able to reproduce the issue. Using the cloningInfo property in a template does not clone the managed identity setting.

"cloningInfo": {
     "sourceWebAppId": "[resourceId('Microsoft.Web/Sites/', 'myWebSiteName')]"
}

@bmoore-msft Who can have a look at this issue?