azureiisazure-web-app-servicesession-state-server

How to execute appcmd on Azure Web App box?


I'd like to execute a

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

command on the box belonging to an Azure Web App. The console is a "sandbox environment", so I don't necessarily expect to have enough privileges, but appcmd is not recognized as a command.

Same thing happened with the KUDU special console - which looked more promising in terms of potential privileges to carry out the task -, both with the CMD and the PowerShell console.

My main goal is to start the IIS's State Server. 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 quotes appcmd.


Solution

  • Per your link in your question: Startup tasks are for web/worker roles in Cloud Services, not Web Apps (completely different things; web/worker role instances are Windows Server instances, not a sandboxed environment).

    You cannot enable IIS State Server on Web Apps. You'll need to store your session state in something like Redis Cache service, which runs independent of Azure Web Apps. Really, you can use any cache (or storage) you want that's external to the Web App sandbox, as long as you have proper drivers/providers for what you choose.