如何在 Azure Web App box 上执行 appcmd?

How to execute appcmd on Azure Web App box?

我想执行一个

appcmd set config /commit:WEBROOT /section:sessionState /mode:StateServer /stateConnectionString: tcpip=loopback:42424 /stateNetworkTimeout: 120 /useHostingIdentity:True

属于 Azure Web 应用程序的框上的命令。控制台是一个"sandbox environment",所以我不一定期望有足够的权限,但是appcmd 不被识别为命令。

同样的事情发生在 KUDU 特殊控制台上——在执行任务的潜在特权方面看起来更有希望——在 CMD 和 PowerShell 控制台上都是如此。

我的主要目标是启动 IIS 的状态服务器。 How to start ASP.Net State Service in Azure mentions "startup task", but I couldn't figure out how to do that. https://technet.microsoft.com/en-us/library/cc732412(v=ws.10).aspx 引用 appcmd.

根据您在问题中的 link:启动任务适用于云服务中的 web/worker 角色,而不是 Web 应用程序(完全不同;web/worker 角色实例是 Windows 服务器实例,而不是沙盒环境)。

您不能在 Web 应用程序上启用 IIS 状态服务器。您需要将会话状态存储在诸如 Redis 缓存服务之类的东西中,它独立于 Azure Web 应用程序运行。实际上,您可以使用 Web App 沙箱外部的任何缓存(或存储),只要您有合适的 drivers/providers 即可。