How to setup Azure App Service to run on .Net Core

2020-03-24 07:52发布

问题:

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:

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?

回答1:

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