6

I've set-up an App Service using the following ARM template snippet:

{
  "name": "[variables('webBackEnd')]",
  "type": "Microsoft.Web/sites",
  "location": "[parameters('location')]",
  "apiVersion": "2015-08-01",
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
  ],
  "tags": {
    "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName')))]": "Resource",
    "displayName": "BackendWebApp"
  },
  "properties": {
    "name": "[variables('webBackEnd')]",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
  }
},

This will deploy an App Service. However, by default, it will be setup to use the .Net Framework. Below is a view from my Azure Portal:

App Service configured to run .Net Framework

In order to run my ASP.Net Core-based web server, I have to manually switch the Stack Settings from ".Net" to ".Net Core". It's a trivial thing to do, but I'd much rather configure it correctly through the ARM template. I searched Microsoft's docs but was unable to find the correct property. How does one go about to do this?

djf
  • 6,592
  • 6
  • 44
  • 62

2 Answers2

18

here's how an example web app looks when created from the portal:

{
    "apiVersion": "2018-02-01",
    "name": "[parameters('name')]",
    "type": "Microsoft.Web/sites",
    "location": "[parameters('location')]",
    "properties": {
        "name": "[parameters('name')]",
        "siteConfig": {
            "appSettings": [],
            "metadata": [
                {
                    "name": "CURRENT_STACK",
                    "value": "[parameters('currentStack')]"
                }
            ]
        },
        // redacted some values
    }
},

and the current stack value is dotnetcore

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Very interesting. When I create an App Service in the Portal, the runtime will be preset to ".Net Core". But I don't see any difference in the exported ARM template. Moreover, the "metadata" property which seems to control the stack setting is not documented in [Microsoft.Web sites template reference](https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2018-11-01/sites) – djf Sep 18 '19 at 07:45
  • 1
    template reference is garbage, unfortunately – 4c74356b41 Sep 18 '19 at 07:56
  • 1
    I verified that your solution works as intended. Thanks! – djf Sep 18 '19 at 08:23
  • I confirm that this configuration works to set the Web App stack to .NET Core. Although, it seems the Web App needs to be "Restarted" for the .NET Core support to fully work after initial deployment. Seems to be a bug with this currently... – Chris Pietschmann Sep 21 '19 at 23:49
  • 4
    Given that the reference is garbage, and that the portal is not generating the CURRENT_STACK metadata thing, how on earth did you find out? – Esben Bach Nov 07 '19 at 13:45
  • ugh, this was long time ago, I'm not sure exactly, I think I created an App Service using the portal and set it to use dotnetcore and examined the template that the portal used to create the webapp with those settings. ps. I'd also appreciate an upvote ;) @EsbenBach – 4c74356b41 Nov 07 '19 at 14:17
  • @4c74356b41 I have to ask this: As Esben Back said the exported template does NOT show metadata how did you find out then? What do you mean by "examined the template"? – Alexander Schmidt Apr 16 '20 at 10:37
  • 1
    sorry, I answer hundreds of questions here, I dont really remember. i guess what it says. start creating the webapp and look at the template that gets used before you hit create? @AlexanderSchmidt – 4c74356b41 Apr 16 '20 at 14:28
  • See this question for a comment about discovering this during creation in portal: https://stackoverflow.com/questions/59140969/arm-template-azure-web-app-how-do-you-specify-stack-settings-net-net-core – Noah Stahl Sep 22 '20 at 22:33
1

The accepted answer didn't work for me. I began my own investigation and finished with this code, which works in my case.

"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[parameters('site_name')]",
"location": "[resourceGroup().location]",
.........................................

"resources": [
 {
    "name": "metadata",
    "type": "config",
    "apiVersion": "2018-11-01",
    "dependsOn": [
        "[resourceId('Microsoft.Web/sites', parameters('site_name'))]"
    ],
    "tags": {
    },
    "properties": {
        "CURRENT_STACK": "dotnetcore"
    }
 }
]
David Buck
  • 3,752
  • 35
  • 31
  • 35