August 12, 2023 by Anuraj Estimated read time : 5 mins
This post is about configuring continuous database deployments to Azure Sql Server with Bitbucket. We are deploying it using EF Core migrations. We can can modify the existing bit bitbucket-pipelines.yml file and add the following code.
We need to create a CONNECTION_STRING variable in the Bitbucket repository variables, with the Azure Sql Server connection string. Here is the screenshot of the build pipelines.
And here is the complete YAML file.
If we run the pipeline, it may fail because to run query in Azure SQL, we need to enable or whitelist the IP Addresses. We can either manually add Bitbucket IP addresses or we can run the following powershell code.
Or we can update the pipeline and include Azure CLI pipeline steps to add and remove the build pipeline server IP address, something like this.
We can add this step before Database deployment step and we can add code remove the IP Address using the following code - which we can add after the Database deployment step.
Here is the final build pipeline.
This way we can configure continuous database deployment from Bitbucket to Azure Sql Server with EF Core. For the demo purposes I created everything in build pipelines. We can refactor the pipeline and configure deployment section instead of everything in build.