使用 ARM 模板更改 Web 应用程序 .NET 框架版本

Change web app .NET framework version with ARM template

我正在将现有的网络应用程序更新到 .NET 5。有一个描述网络应用程序配置的 ARM 模板。

在我添加的ARM模板中

  "netFrameworkVersion": "v5.0",

Microsoft.Web/sites/config properties 对象内。

ARM 模板部署成功,但 Web 应用程序配置未从 .NET Core 3.1 更改为 .NET 5。

奇怪的是,当我查看 Azure Resource manager 时,它 确实 包含 netFrameworkVersion 净值。

此配置是我要更改为 .NET 5 的配置:

我是否缺少设置,或者无法使用 ARM 模板更新 .NET 版本?

除了需要更改的 netFrameworkVersion 之外,您还需要向模板中的 resources 添加另一个资源,只需像下面这样添加,它在我这边工作正常。

注:针对OS为Windows.[=16=的web应用]

    {
        "type": "Microsoft.Web/sites/config",
        "apiVersion": "2018-11-01",
        "name": "[concat(parameters('webapp_name'), '/metadata')]",
        "location": "Central US",
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
        ],
        "properties": {
            "CURRENT_STACK": "dotnet"
        }
    }

我的完整样本:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "webapp_name": {
            "defaultValue": "joyweb11",
            "type": "String"
        },
        "serviceplan_resourceid": {
            "defaultValue": "/subscriptions/xxxxx/resourceGroups/xxxx/providers/Microsoft.Web/serverfarms/joyplan",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-11-01",
            "name": "[parameters('webapp_name')]",
            "location": "Central US",
            "tags": {},
            "kind": "app",
            "properties": {
                "enabled": true,
                "hostNameSslStates": [
                    {
                        "name": "[concat(parameters('webapp_name'), '.azurewebsites.net')]",
                        "sslState": "Disabled",
                        "hostType": "Standard"
                    },
                    {
                        "name": "[concat(parameters('webapp_name'), '.scm.azurewebsites.net')]",
                        "sslState": "Disabled",
                        "hostType": "Repository"
                    }
                ],
                "serverFarmId": "[parameters('serviceplan_resourceid')]",
                "reserved": false,
                "isXenon": false,
                "hyperV": false,
                "siteConfig": {},
                "scmSiteAlsoStopped": false,
                "clientAffinityEnabled": true,
                "clientCertEnabled": false,
                "hostNamesDisabled": false,
                "containerSize": 0,
                "dailyMemoryTimeQuota": 0,
                "httpsOnly": false,
                "redundancyMode": "None"
            }
        },
        {
            "type": "Microsoft.Web/sites/config",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('webapp_name'), '/web')]",
            "location": "Central US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
            ],
            "tags": {
                
            },
            "properties": {
                "numberOfWorkers": 1,
                "defaultDocuments": [
                    "Default.htm",
                    "Default.html",
                    "Default.asp",
                    "index.htm",
                    "index.html",
                    "iisstart.htm",
                    "default.aspx",
                    "index.php",
                    "hostingstart.html"
                ],
                "netFrameworkVersion": "v5.0",
                "requestTracingEnabled": false,
                "remoteDebuggingEnabled": false,
                "remoteDebuggingVersion": "VS2019",
                "httpLoggingEnabled": false,
                "logsDirectorySizeLimit": 35,
                "detailedErrorLoggingEnabled": false,
                "publishingUsername": "$joyweb11",
                "azureStorageAccounts": {},
                "scmType": "None",
                "use32BitWorkerProcess": true,
                "webSocketsEnabled": false,
                "alwaysOn": true,
                "managedPipelineMode": "Integrated",
                "virtualApplications": [
                    {
                        "virtualPath": "/",
                        "physicalPath": "site\wwwroot",
                        "preloadEnabled": true
                    }
                ],
                "loadBalancing": "LeastRequests",
                "experiments": {
                    "rampUpRules": []
                },
                "autoHealEnabled": false,
                "localMySqlEnabled": false,
                "ipSecurityRestrictions": [
                    {
                        "ipAddress": "Any",
                        "action": "Allow",
                        "priority": 1,
                        "name": "Allow all",
                        "description": "Allow all access"
                    }
                ],
                "scmIpSecurityRestrictions": [
                    {
                        "ipAddress": "Any",
                        "action": "Allow",
                        "priority": 1,
                        "name": "Allow all",
                        "description": "Allow all access"
                    }
                ],
                "scmIpSecurityRestrictionsUseMain": false,
                "http20Enabled": false,
                "minTlsVersion": "1.2",
                "ftpsState": "AllAllowed",
                "reservedInstanceCount": 0
            }
        },
        {
            "type": "Microsoft.Web/sites/hostNameBindings",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('webapp_name'), '/', parameters('webapp_name'), '.azurewebsites.net')]",
            "location": "Central US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
            ],
            "properties": {
                "siteName": "[parameters('webapp_name')]",
                "hostNameType": "Verified"
            }
        },
        {
            "type": "Microsoft.Web/sites/config",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('webapp_name'), '/metadata')]",
            "location": "Central US",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
            ],
            "properties": {
                "CURRENT_STACK": "dotnet"
            }
        }
    ]
}