The problem with deployment slots and Terraform state If this sounds new to you I recommend reading my first post about Terraform, as well as some content on App Service (see the overview, app settings and deployment slots pages from the official documentation). I have been using all of these for several projects over the years, but once we have started using IaC (especially Terraform), things became complicated as swap operations were messing up with the Terraform state.Īfter almost stopping using slots over the last few years, I have finally found an approach to make them work using Terraform and I’m happy to share it in this post.īy writing this post I assume you already have a good understanding of Terraform and App Service, at least you have tried to use them together 😉 All of this without causing downtime.Īnother main feature of App Service is configuration with app settings, who are environment variables set at the service level and injected to the application code.
You can create a staging slot to deploy the new version of your code, test it and swap with the production slot once ready to make the new version go live. When you want to implement blue-green deployment using Azure App Services, deployment slots is the way to go.