I am planning a continuous deployment process in VSTS that will include deploying a resource group in Azure using an ARM template. That resource group will include a SQL database. After initial deployment, I don't want to lose any data stored in that database on subsequent deployments, so I need to understand what happens to existing data if a change is made to the ARM template, especially if the change affects the provisioning of the database. Do I need to add steps to my CD process to check if the resource group/database exists and back it up before deploying the ARM template? I have the same curiosity with regard to blob storage -- is it "wiped clean" on each redeployment?
1 Answers
ARM templates won't delete and re-provision. They will:
Check to see if the requested resource exists in the specified subscription and region. If the resource doesn't exist, it will create it. This assumes that the resource name is available. For example, provisioning a Web App with the name FooBar will fail if there is already a foobar.azurewebsites.net.
Ensure that all settings in the specified resource match what is specified in the ARM template. For example, if you have an Azure SQL DB that is currently scaled to S0, and your template defines the database as a S3, your database will be an S3 after deployment.
Any settings in an existing resource that are NOT specified in the ARM template will be left alone by the ARM template deployment.
Edit: as 4c74356b41 mentioned, don't use complete deployment mode.
As a further safeguard, lock your database that you absolutely positively do not want deleted with a Delete lock.