Stackify is now BMC. Read theBlog

Testing in Production with Microsoft Azure

  |  March 1, 2018
Testing in Production with Microsoft Azure

_ How do you test that a feature in your application actually works? Or that it is actually being used?

Usually, you’d perform lots of tests in separate environments, like a QA or Acceptance environment. Or you’d route a certain percentage of your production traffic to the new version of your site to test if and how usage of your new features. This latter approach used to be very difficult. You had to implement and configure a load balancer to route some of the traffic to the new version of your application.

Microsoft Azure makes all of this much easier. First of all, you can easily host your application in Azure App Services. These are managed services in Azure that you can use to easily run your web applications and APIs. They scale automatically and have features like easy authentication and deployment slots.

Azure App Services deployment slots

Azure App Services deployment slots can help you to set up different environments for your application easily. A deployment slot is simply an identical hosting environment that can host the new version of your app, next to your existing environment. If you run your application in an Azure Web App, a deployment slot is a Web App that lives right next to that.

The main advantage of having deployment slots is that they allow you to easily push the new version of your application to production by performing a swap operation. This ensures that your application is warmed up before it goes into production, which enables you to deploy without any downtime.

Deployment slots are great and can provide several environments for you. But how can they help you to test out new features on some of your users? As you’ve expected; Azure has a feature for this and it is actually called Testing in Production. Let’s explore it!

Using the App Services Testing in Production feature

Testing in Production is a feature of Azure App Services and, you guessed it, it allows you to test in production. It uses deployment slots to do so. It’s actually very easy to configure and use.

In the Azure Portal, in the blade of your Web App, you’ll find the Testing in Production feature. There you can tell it to route a certain percentage of production traffic to one of your deployment slots. I’ve chosen to route 20% of production traffic to the qa deployment slot, which contains the new version of my application.

Now 20% of my users see the new version of my app and are actually testing it in production. And I can easily turn this off, or tweak it to route more or less traffic. And all I had to do to enable it was to click a few buttons and hit save. Azure takes care of the load balancer, and it is even included in the price of the App Service.

Keep in mind that when you do something like this, you need to make sure that the new version of your application in the deployment slot is connected to the same data as production, and is able to use the same authentication mechanisms and third-party services. These things might need additional configuration as a deployment slot has a different URL than your production slot, although users don’t notice that when they are routed through the Testing in Production feature.

Measuring everything

It’s nice that some users access the new version of my app, but how do I know that it actually works? Or if new features are actually being used? To find out, I need to gather as much information as possible by instrumenting my application.

There are many tools for measuring application usage and things like performance and exceptions. There are tools like Application Insights and Stackify Retrace. I currently prefer the latter because it can show me all of the exceptions that happen in my app, without explicitly having to instrument my application for it. Instrumenting your app with Stackify Retrace is really easy. This article on the Stackify Blog explains how to make Retrace work with ASP.NET Core and Azure.

Using tools like these, you can find out what your users are doing. Find out if and how they are using your new features, and find out if everything is working correctly and as performant as in the previous version of your application.

Conclusion

Testing is very important and setting up environments and testing in production can be difficult to do without the power of Microsoft Azure.

Azure App Services deployment slots make it very easy to have multiple environments to test in. And the Testing in Production feature allows you to route production traffic to one of those deployment slots with a few clicks.

This is the Azure cloud at its best. Like I always say: Azure takes care of the plumbing and all of the boring and difficult stuff, so that you can focus on building things that really matter.

Let me know what you think in the comments.

 

Improve Your Code with Retrace APM

Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.

Learn More

Want to contribute to the Stackify blog?

If you would like to be a guest contributor to the Stackify blog please reach out to [email protected]