You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过ARM JSON模板开启Azure WebApp的WebSocket功能?

解决Azure ARM模板开启WebApp WebSocket无效的问题

我最近尝试用ARM JSON模板部署Azure WebApp时,遇到了WebSocket始终无法开启的问题——先后试过webSocketsEnabled和WebSockets两种配置项都没效果,我的初始配置片段是这样的:

"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",但依然无效,而且VS的参数智能提示里只允许使用"2015-08-01"
  • 试过别人分享的有效方案也没解决,后来推测问题出在更新已部署的基础设施的场景下,且当前WebApp的定价层不支持AlwaysOn功能
  • 最后决定移除AlwaysOn参数,重新部署模板

最终解决方案

移除siteConfig里的AlwaysOn配置后,模板成功生效,WebSocket功能顺利开启。修正后的核心配置片段如下:

"siteConfig": {
  "webSocketsEnabled": true,
  "connectionStrings": [ { ... }, { ... } ]
}

总结一下:如果是更新已存在的WebApp,且当前定价层(比如免费层、共享层)不支持AlwaysOn,这个不兼容的配置会导致整个siteConfig的更新失效,连带WebSocket的配置也无法生效。移除不支持的参数后,WebSocket的配置就能正常应用了。

内容的提问来源于stack exchange,提问作者François

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:39:52