首页 > 解决方案 > Azure - 从 ARM json 模板设置 WebSocket

问题描述

我正在尝试从部署我的整个基础架构的 Azure ARM json 模板为 Azure WebApp 打开 WebSockets。

这是关于 Azure Web App 的摘录。它不起作用,即 WebSockets 仍然关闭。我没有成功尝试不同的拼写:webSocketsEnabledWebSockets

"resources":[
{
  "name": "[variables('MyApp')]",
  "type": "Microsoft.Web/sites",
  "location": "Brazil South",
  "apiVersion": "2016-08-01",
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', variables('MyAppPlanBrazil'))]"
  ],
  "tags": {
    "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('MyAppPlanBrazil')))]": "Resource",
    "displayName": "MyAppAppBrazil"
  },
  "properties": {
    "name": "[variables('MyAppPlanBrazil')]",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('MyAppPlanBrazil'))]",
    "siteConfig": {
      "AlwaysOn": true,
      "webSocketsEnabled": true,
      "connectionStrings": [
        {
        ...
        },
        {
        ...
        },
      ]
    }
  }
 ] 

更新

正如下面的答案中所建议的,我将其更新apiVersion"2016-08-01"但这仍然不起作用。另请注意,虽然我的架构此处描述的架构,但apiVersion在 VS 中是波浪形的,它表示授权值"2015-08-01"仅为。

更新2

我尝试了以下解决方案。他们为他们的作者工作,但不为我工作。我想问题出在其他地方。我的基础架构已经部署,我尝试使用webSocketsEnabled. 而在下面的解决方案中,我想作者直接使用webSocketsEnabled.

此外,我的 web 应用程序webSocketsEnabledalwaysOn定价层不允许“AlwaysOn”(正如门户网站中所说,我需要升级才能使用该功能),所以我会尝试不使用alwaysOn.

更新3

最后,上面的模板在我删除AlwaysOn. 感谢那些试图帮助我的人。

标签: azureazure-resource-manager

解决方案


将您的 api 版本设置为:“2016-08-01”

利用

“webSocketsEnabled”:真

这是来自 Microsoft.Web/sites 模板参考:

https://docs.microsoft.com/en-us/azure/templates/microsoft.web/sites

您使用的 api 版本 (2015-08-01) 来自:

https://github.com/Azure/azure-resource-manager-schemas/blob/master/schemas/2015-08-01/Microsoft.Web.json

其中没有网络套接字,但后者:

https://github.com/Azure/azure-resource-manager-schemas/blob/master/schemas/2016-08-01/Microsoft.Web.json

有 webSocketsEnabled。


推荐阅读