Azure Load Testing (PaaS) using Apache JMeter
Tags: azure, github, devops, testing
Published: 2022-06-27 22:04:13

## Overview
Azure Load Testing is a new managed load testing service from Microsoft (currently in preview) that lets you simulate volumes of traffic to your website regardless of where you are hosting your application. It uses Apache JMeter to both define and run the loads tests.

This can be specifically useful if you have a website that needs to scale on demand to meet peak performance requirements. Microsoft seem to be adding more abstraction layers in Azure which is nice to see and previously you would have to run these JMeter tests on your own compute environment or virtual machines. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ks9vop2n5ndrlyxy2cpt.png)

In this article we are going to look at how you can create a sample load testing in the portal. The service is currently in preview and it seems like only manual deployment through the portal is available. There is also a comprehensive guide from MS on how you can can automate the load testing through CI/CD using Github actions so I won't be repeating something that is already well [documented](https://docs.microsoft.com/en-us/azure/load-testing/tutorial-cicd-github-actions).

## Create the Load Testing Service

**Step 1:** Navigate to the Azure marketplace and search for "Azure Load Testing". You can also try the following [link](https://portal.azure.com/#view/HubsExtension/BrowseResource/resourceType/Microsoft.LoadTestService%2FLoadTests) after you have logged into the portal.

**Step 2:** Fill out the required details. In my case I set up a new resource group for the service and click "create". 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugsj03brzer2lg9br3cg.png)
  
**Step 3:** Navigate to the service once it's deployed. It should spin up in a few minutes. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9c1vlapikyr430zniiy6.png)
 

## Create the Load Test and View the Results

For the purposes of this demo we are going to set up one of the out the box tests which will hit an endpoint we specify. You can optionally upload your own JMeter scripts. 

**Step 1:** Navigate to the "tests" blade in the left pane

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0jpy3nuaeufsblvocx4.png)

**Step 2:** Input the required parameters. Here you can specify how many users you would like to simulate the load for, the test duration and the ramp up time for the virtual users. For the purposes of this demo we are going to load `www.google.co.uk`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isopvljjxpeglpf7yf0w.png)

**Step 3:** The test will start running and it should complete based on the duration specified in the previous step:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6lxao3t3t9tg5u5kcc22.png)
 
**Step 4:** Once the test completes you can navigate over and analyse the results: 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijs5yxrjwd3hgslgjbmd.png)

You can optionally export the results. For this test we defined no pass criteria so the test result will display as "not applicable". 
  

## Conclusion
 

This is certainly a neat new service to see from Microsoft. The big issue with load testing is having to spin up compute to execute your tests and then integrating this into your CI/CD from scratch. A lot of this friction is removed with this service. 

This is only a fraction of the functionality so be sure to check out the Microsoft [docs](https://docs.microsoft.com/en-us/azure/load-testing/overview-what-is-azure-load-testing) for more info.

Microsoft also provide full CI/CD [integration](https://docs.microsoft.com/en-us/azure/load-testing/tutorial-cicd-github-actions) for Azure load testing using Github actions meaning you can automatically run these tests when creating a PR (or any other trigger) and define pass/fail criteria which embeds load testing into the core of the software development lifecycle. I can also see a use for this when deploying infrastructure changes through IaC where changing the sizing of your compute may impact the performance when under high load.