0
votes

I have an ARM template that created an Azure app service, it worked well for .NET Core but I now want to update the template to deploy a NET 5 app service, I'm not having any luck. Here's the ARM schema: https://docs.microsoft.com/en-us/azure/templates/microsoft.web/sites

Here's an extract from the template, I run this but when I look in the portal the site is created with a .NET Framework version of ASPNET 4.8. How to deploy a NET 5 site with an ARM template?

    {
      "name": "[variables('apiAppServiceName')]",
      "type": "Microsoft.Web/sites",
      "apiVersion": "2020-06-01",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[variables('hostingPlanName')]",
        "[variables('databaseName')]",
        "[variables('storageAccountName')]"
      ],
      "tags": {
        "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]": "empty",
        "displayName": "Website",
        "environment": "[parameters('environment')]"
      },
      "properties": {
        "name": "[variables('apiAppServiceName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "httpsOnly": true,
        "clientAffinityEnabled": false,
        "netFrameworkVersion": "net5.0"
      },
3
Hello, is there any updates on the question? I agree with Krzysztof Madej's answer that net5.0 is not a legal value for netFrameworkVersion. Please check whether his answer can help you and feel free to comment.Jane Ma-MSFT

3 Answers

3
votes

Looking at template generated by Azure:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "subscriptionId": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "location": {
            "type": "string"
        },
        "hostingPlanName": {
            "type": "string"
        },
        "serverFarmResourceGroup": {
            "type": "string"
        },
        "alwaysOn": {
            "type": "bool"
        },
        "currentStack": {
            "type": "string"
        },
        "phpVersion": {
            "type": "string"
        },
        "netFrameworkVersion": {
            "type": "string"
        }
    },
    "resources": [
        {
            "apiVersion": "2018-11-01",
            "name": "[parameters('name')]",
            "type": "Microsoft.Web/sites",
            "location": "[parameters('location')]",
            "tags": null,
            "dependsOn": [],
            "properties": {
                "name": "[parameters('name')]",
                "siteConfig": {
                    "appSettings": [],
                    "metadata": [
                        {
                            "name": "CURRENT_STACK",
                            "value": "[parameters('currentStack')]"
                        }
                    ],
                    "phpVersion": "[parameters('phpVersion')]",
                    "netFrameworkVersion": "[parameters('netFrameworkVersion')]",
                    "alwaysOn": "[parameters('alwaysOn')]"
                },
                "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                "clientAffinityEnabled": true
            }
        }
    ]
}

and paramaters

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "subscriptionId": {
            "value": "someId"
        },
        "name": {
            "value": "testdotnet5"
        },
        "location": {
            "value": "Central US"
        },
        "hostingPlanName": {
            "value": "ServicePlan43e7dac6-ad18"
        },
        "serverFarmResourceGroup": {
            "value": "recruiterly"
        },
        "alwaysOn": {
            "value": false
        },
        "currentStack": {
            "value": "dotnet"
        },
        "phpVersion": {
            "value": "OFF"
        },
        "netFrameworkVersion": {
            "value": "v5.0"
        }
    }
}

You should use

        "netFrameworkVersion": {
            "value": "v5.0"
        }
1
votes

On top of the issue with the wrong value, you've also got the netFrameworkVersion in the wrong section, in properties rather than properties->siteconfig. Something like this should sort you out:

{
  "name": "[variables('apiAppServiceName')]",
  "type": "Microsoft.Web/sites",
  "apiVersion": "2020-06-01",
  "location": "[parameters('location')]",
  "dependsOn": [
    "[variables('hostingPlanName')]",
    "[variables('databaseName')]",
    "[variables('storageAccountName')]"
  ],
  "tags": {
    "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]": "empty",
    "displayName": "Website",
    "environment": "[parameters('environment')]"
  },
  "properties": {
    "name": "[variables('apiAppServiceName')]",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
    "httpsOnly": true,
    "clientAffinityEnabled": false,
    "siteconfig" : {
       "netFrameworkVersion": "v5.0"
    }
  },
0
votes

The parameter settings mentioned previously did not do it for me. Validation of the ARM template kept bombing out complaining that value for netFrameworkVersion had to be null. Changing it to defaultValue got me passed that.

"netFrameworkVersion": {
  "type": "string",
  "defaultValue": "v5.0"
},