Reputation: 7391
I'm trying to achieve zero downtime deployments of an Azure web app where database schema updates need to be applied as part of the deployment.
I have the following setup:
Production web app with production-db connection string.
Staging deployment slot with staging-db connection string.
My pseudo-deployment process is something like:
In other words, after the hot swap, I want both the new code and the updated database to be live.
If something goes wrong at this point, I can simply swap slots again, making the old production app (and its database) go live.
As I understand it now, when I swap slots, the app will use the connection string of the production slot, restarting the app and forcing me to apply the database schema updates after the updated code goes live.
I hope I'm describing this properly. :) This seems like it should be a fairly common scenario?
Any help or pointers are greatly appreciated!
PS. I've looked at Azure seamless upgrade when database schema changes, but that answer isn't valid, as I can't apply the schema updates without affecting the application.
Edit: Just a thought: perhaps I should skip putting the connection string as a portal setting, and instead just keep it in web.config. That way, when swapping, the app won't need to restart, and since web.config will be included in the swap, the new production slot will use the updated database.
Edit 2: I think I was mistaken about the app restart when app settings or connection strings differ between slots. It seems I can indeed set a different connection string (pointing to the database copy) for the deployment slot, and then swap without an app restart affecting website visitors.
Upvotes: 10
Views: 3656
Reputation: 914
Could you not make the connection string sticky to the slot?
Full details are here.
Upvotes: 0