Crowdbotics
Published in

Crowdbotics

Canary deployment with Microsoft Azure Web Apps

Photo by Andreas P. on Unsplash

Blue-green deployment allows services to be swapped with zero downtime but what about the possible errors in the new deployments. Microsoft Azure allows to traffic-route your audience from production to staging, making sure that you don’t have an important bug in the new deployment.

In this article I will show how to achieve a canary deployment with a simple script that can be integrated within your favorite devops tool. For the record, a very good article was written by Scott Hanselman but he used PowerShell.

With az webapp traffic-routing command I have created a small script that given:

  • web app name
  • resource group
  • minutes that last the canary deployment
  • percentage change step

it allows you to route the traffic in a controlled manner.

Here is the code:

https://gist.github.com/javitoHertfy/a277092b33aff18195bd083f4b7faf96

Finally all you have to do is to integrate this script in your favorite devops pipeline. Since we use Azure DevOps I will show how our release pipeline is configured.

We have 3 steps:

  • PRO step, deploys the app in the staging slot, warms up the application and run some integration and load tests.
  • Traffic-routing step, only contains the code I shared above but removing the last line that makes the swap.
  • Finally, the Swap task only swaps the two slots.
Steps in the build

This is how the traffic-routing step looks like.

Traffic-routing Azure CLI step

Troubleshooting

  • Since is a bash script better if you run it over a Linux Agent Job.
  • I found some weird issues with the File Format of the bash script, using vscode and windows just change End Of Line sequence from CRLF to LF and saving the file should do the trick.
Changing from CRLF to LF

Hope you found it useful!

--

--

--

The fastest way to build your next app.

Recommended from Medium

#[Clymene] time series data collection platform for distributed systems — official release

Accelerating H264 decoding on iOS with FFMPEG and VideoToolbox

How to root Color K20

Root LG Phone

Imperative vs declarative programming

Stop Installing Python Packages Globally — Use Virtual Environments

WEEKLY UPDATE | Week 12

Configuring fluentd for logging in Kubernetes in under 15 minutes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Javier Hertfelder

Javier Hertfelder

More from Medium

Good to know Azure DevOps Build Triggers

Using Azure Application Gateway for an Intranet Application

Deploy Zscaler App Connector in Azure using Infrastructure-as-Code with Bicep Language

Azure Routing and Peering Basics