I have worked with Azure Service Bus for years and one of the biggest challenges was always how to manage change on the Queues and Topics within a Service Bus Namespace. You could use a tool like Service Bus Explorer to manually make the changes, but this approach is manual and error prone. You can do exports and imports of configuration but a bit like managing SQL Script changes it’s tough to work out the delta and deploy just what’s needed to your various environments. If only there was a way to do this just like you do for any other Azure component with CI and CD pipelines.
Well fortunately, there is if you take a look at Terraform.
Terraform is a tool for writing infrastructure as code but is very self-documenting and it comes with an excellent Azure provider which has lots of good stuff for Azure Service Bus. Using Terraform, you can document your Queues, etc in a simple JSON like format as shown below.
The way Terraform works also allows you to breakdown the definition of your Service Bus across several files allowing interesting ways to break out the definitions to make them more manageable for even the biggest of namespaces.
Once you document the requirements for your Service Bus, you can then manage the deployment to environments by using Terraforms various commands. I have produced 3 videos showing how you can use this approach at various parts of the ALM lifecycle.
Using Terraform as a Developer to Create your Service Bus
In this video, we will look at how the developer creates the Terraform files and how they can be ran on your local machine. You can also check if they work ok setting up the Service Bus as you intended.
Using Terraform in an Azure DevOps Build Pipeline
In this video, we will show how the developer checked in changes which trigger a build pipeline which will do a build to validate our Service Bus can be setup and configured appropriately before publishing artefacts from a successful build for use in a release pipeline.
Using Terraform to deploy changes to environments in an Azure DevOps Release Pipeline
In this video, we will walk through the process of taking the published artefacts from the build pipeline and creating a release pipeline so that we can deploy the Service Bus changes to various environments.
The code samples for this demo is available here.
More about Service Bus
In Serverless360, we have a significant number of features which complement the use of the Azure Service Bus which will help improve the maturity of its use in your organisation. It also make it possible to democratize the management of many Service Bus support tasks away from your development teams to free up their time from support. You can find out more about these features on this link.