So, you have a production deployment that has its own Azure SQL database and an intermediate deployment that has its own Azure SQL database. In this situation, both applications have a connection string pointing to two different databases.
Your first requirement is to change the database schema on the fly when you change the deployment or do something, and I have the following problem with this design:
If you write any code inside a role to perform the action "ONE and only once", there is no guarantee that this will happen only once. This will happen many times, depending on several scenarios, such as
1.1. In any situation that you must redirect to the virtual machine by the system, this CODE will do the same as during the last re-view.
1.2 You can protect it so that it does not execute when the role starts or the VM starts using some registry key of some foreign key, but there is a complete proof mechanism that cannot happen.
Because of this, I would suggest that when you are ready for a SWAP deployment, you can:
2.1 Run the script to update the Azure SQL schema associated with production (this will not affect the loading of the application, since it is untouched, but when your database schema is updated, you can better know how it affects your application)
2.2 Change the configuration in the intermediate deployment to indicate the production of SQL Azure (this will not have any application downtime at all)
2.3 SWAP deployment (this will also not have application downtime)
Thus, even when you manually update the database schema and then deploy SWAP, there is no significant downtime other than the time it takes the database to update the schema.
Avkashchauhan
source share