Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARM template Azure Web App - How do you specify Stack Settings (.NET, .NET Core,...)?

In ARM template for Azure Web App, how do you specify the stack settings for the app (.NET, .NET Core, PHP, ...)? I cannot see any field for it.

Thank you

like image 672
Bertrand Pons Avatar asked Dec 02 '19 14:12

Bertrand Pons


3 Answers

When you create azure webapp on portal, choose Running stack as .Net Core 3.0(Current).

Then click Review+Create > Download a template for automation. You will see the ARM template which contain metadata attribute and the current stack value is dotnetcore.

enter image description here

{
    "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
    }
}
like image 156
Joey Cai Avatar answered Oct 17 '22 19:10

Joey Cai


Adding to Joey's answer, the value for CURRENT_STACK for .NET Core would be dotnetcore.

{
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-11-01",
            "name": "<name>",
            "location": "[resourceGroup().location]",
            "kind": "app",
            "properties": {
                "enabled": true,
                "siteConfig": {
                    "metadata": [
                        {
                            "name": "CURRENT_STACK",
                            "value": "dotnetcore"
                        }
                    ]
                }
            }
        }
like image 2
El Mac Avatar answered Oct 17 '22 18:10

El Mac


As a small note: This proposed solution does only work for NEW WebApps... if you want to CHANGE an existing WebApp from .Net4.x to .NetCore you also must clear "netFrameworkVersion". Otherwise the stack is not changed.

So correct would be:

{
    "apiVersion": "2018-02-01",
    "name": "[parameters('name')]",
    "type": "Microsoft.Web/sites",
    "location": "[parameters('location')]",
    "properties": {
        "name": "[parameters('name')]",
        "siteConfig": {
            "appSettings": [],
            "netFrameworkVersion": "",
            "metadata": [
                {
                    "name": "CURRENT_STACK",
                    "value": "dotnetcore"
                }
            ]
        },
        // redacted some values
    }
}
like image 1
Jochen Kalmbach Avatar answered Oct 17 '22 20:10

Jochen Kalmbach