I'm having trouble with an Azure App Service Deployment. I'm using VSTS to do the deployment using the Azure App service Deploy feature. I'm deploying a Docker container to a Linux App Service slot. The Docker container is running a Node.js WebSocket server that, on connect, messages back with the current app version based on a text file created as part of the build.
In my client app, I have it setup to grab the app version from the WebSocket server when a message comes in. It's role is determining if the WebSocket server version matches the client version. When the WebSocket connection is lost because of a restart or a deployment, the client app will try to reconnect until the WebSocket server comes back online.
Deployments seem to create 2 versions of the app service. One being the original and the other being the latest deployment. If I have a browser window open, it should notice a deployment occurred and notify me the app version has changed. This seems to happen sporadically.
The only way to be sure the client app notices the app version changing is manually restarting the app service via the Azure portal or by refreshing the browser window. Otherwise, the browser will not trigger the WebSocket
onclose or would trigger it between 2-40 minutes later. While I'm fine with 2 minutes, I'm not fine with anything over 5.
When I run this locally, I don't experience any of these problems so I attribute them to the Azure environment.
When I do the deployment release in VSTS by itself, it seems random when the WebSocket connection closes, but it does occur within that 2-40 minute timeframe.
I tried setting my VSTS Release to restart the App Service after deploying, but then only a few browsers would noticed the WebSocket connection closing.
In another VSTS Release, I had the App Service restart before deploying. This worked for only 50% of deployments. The rest would not trigger.
I also tried setting the VSTS Release to stop the app service, deploy the change, and then start it again. This had about an 80% chance of updating the deployed version.
How can I ensure that after a deployment to an Azure App Service, the previous running WebSocket connection disconnects immediately and not some undetermined time later?