Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Azure App Service to run on .Net Core through Azure Resource Manager

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?

like image 534
djf Avatar asked Sep 17 '19 18:09

djf


2 Answers

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

like image 127
4c74356b41 Avatar answered Oct 21 '22 03:10

4c74356b41


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"
    }
 }
]
like image 40
Serhii Polchaninov Avatar answered Oct 21 '22 01:10

Serhii Polchaninov