Quickstart: Create and run a load test with Azure Load Testing Preview

This quickstart describes how to create an Azure Load Testing Preview resource by using the Azure portal. With this resource, you'll create a load test with an Apache JMeter script and run the test against an external website.

After you complete this quickstart, you'll have a resource and load test that you can use for other tutorials.

Learn more about the key concepts for Azure Load Testing.

Important

Azure Load Testing is currently in preview. For legal terms that apply to Azure features that are in beta, in preview, or otherwise not yet released into general availability, see the Supplemental Terms of Use for Microsoft Azure Previews.

Prerequisites

Create an Azure Load Testing resource

First, you'll create the top-level resource for Azure Load Testing. It provides a centralized place to view and manage test plans, test results, and related artifacts.

If you already have a Load Testing resource, skip this section and continue to Create a load test.

To create a Load Testing resource:

  1. Sign in to the Azure portal by using the credentials for your Azure subscription.

  2. Select the menu button in the upper-left corner of the portal, and then select + Create a resource.

    Screenshot that shows the button for creating a resource.

  3. Use the search bar to find Azure Load Testing.

  4. Select Azure Load Testing.

  5. On the Azure Load Testing pane, select Create.

    Screenshot that shows the Azure Load Testing pane.

  6. Provide the following information to configure your new Azure Load Testing resource:

    Field Description
    Subscription Select the Azure subscription that you want to use for this Azure Load Testing resource.
    Resource group Select an existing resource group. Or select Create new, and then enter a unique name for the new resource group.
    Name Enter a unique name to identify your Azure Load Testing resource.
    The name can't contain special characters, such as \/""[]:|<>+=;,?*@&, or whitespace. The name can't begin with an underscore (_), and it can't end with a period (.) or a dash (-). The length must be 1 to 64 characters.
    Location Select a geographic location to host your Azure Load Testing resource.
    This location also determines where the test engines are hosted and where the JMeter client requests originate from.

    Note

    Optionally, you can configure more details on the Tags tab. Tags are name/value pairs that enable you to categorize resources and view consolidated billing by applying the same tag to multiple resources and resource groups.

  7. After you're finished configuring the resource, select Review + Create.

  8. Review all the configuration settings and select Create to start the deployment of the Azure Load Testing resource.

    When the process has finished, a deployment success message appears.

  9. To view the new resource, select Go to resource.

    Screenshot that shows the deployment completion screen.

  10. Optionally, manage access to your Azure Load Testing resource.

    Azure Load Testing uses role-based access control (RBAC) to manage permissions for your resource. If you encounter this message, your account doesn't have the necessary permissions to manage tests.

    Screenshot that shows an error message in the Azure portal that you're not authorized to use the Azure Load Testing resource.

Create an Apache JMeter script

In this section, you'll create a sample Apache JMeter script that you'll use in the next section to load test a web endpoint. If you already have a script, you can skip to Create a load test.

  1. Create a SampleTest.jmx file on your local machine:

    touch SampleTest.jmx
    
  2. Open SampleTest.jmx in a text editor and paste the following code snippet in the file:

    <?xml version="1.0" encoding="UTF-8"?>
    <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
      <hashTree>
        <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Azure Load Testing Quickstart" enabled="true">
          <stringProp name="TestPlan.comments"></stringProp>
          <boolProp name="TestPlan.functional_mode">false</boolProp>
          <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
          <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
          <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="TestPlan.user_define_classpath"></stringProp>
        </TestPlan>
        <hashTree>
          <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
            <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
            <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
              <boolProp name="LoopController.continue_forever">false</boolProp>
              <intProp name="LoopController.loops">-1</intProp>
            </elementProp>
            <stringProp name="ThreadGroup.num_threads">5</stringProp>
            <stringProp name="ThreadGroup.ramp_time">10</stringProp>
            <boolProp name="ThreadGroup.scheduler">true</boolProp>
            <stringProp name="ThreadGroup.duration">120</stringProp>
            <stringProp name="ThreadGroup.delay">5</stringProp>
            <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
          </ThreadGroup>
          <hashTree>
            <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Homepage" enabled="true">
              <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
                <collectionProp name="Arguments.arguments"/>
              </elementProp>
              <stringProp name="HTTPSampler.domain">your-endpoint-url</stringProp>
              <stringProp name="HTTPSampler.port"></stringProp>
              <stringProp name="HTTPSampler.protocol"></stringProp>
              <stringProp name="HTTPSampler.contentEncoding"></stringProp>
              <stringProp name="HTTPSampler.path"></stringProp>
              <stringProp name="HTTPSampler.method">GET</stringProp>
              <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
              <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
              <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
              <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
              <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
              <stringProp name="HTTPSampler.connect_timeout"></stringProp>
              <stringProp name="HTTPSampler.response_timeout"></stringProp>
            </HTTPSamplerProxy>
            <hashTree/>
          </hashTree>
        </hashTree>
      </hashTree>
    </jmeterTestPlan>
    

    This sample Apache JMeter script simulates a load test of five virtual users simultaneously accessing a web endpoint. It takes less than two minutes to complete.

  3. In the file, replace the placeholder text your-endpoint-url with your own endpoint URL.

    Important

    Don't include https or http in the endpoint URL.

  4. Save and close the file.

Create a load test

With Azure Load Testing, you can use an Apache JMeter script to create a load test. This script defines the application test plan. It contains information about the web endpoint, the number of virtual users, and other test configuration settings.

To create a load test by using an existing Apache JMeter script:

  1. Go to your Azure Load Testing resource, select Tests from the left pane, and then select + Create new test.

    Screenshot that shows the Azure Load Testing page and the button for creating a new test.

  2. On the Basics tab, enter the Test name and Test description information. Optionally, you can select the Run test after creation checkbox.

    Screenshot that shows the Basics tab for creating a test.

  3. On the Test plan tab, select your Apache JMeter script, and then select Upload to upload the file to Azure.

    Screenshot that shows the Test plan tab.

    Note

    You can select and upload additional Apache JMeter configuration files or other files that are referenced in the JMX file. For example, if your test script uses CSV data sets, you can upload the corresponding .csv file(s).

  4. (Optional) On the Parameters tab, configure input parameters for your Apache JMeter script.

  5. For this quickstart, you can leave the default value on the Load tab:

    Field Default value Description
    Engine instances 1 The number of parallel test engines that run the Apache JMeter script.

    Screenshot that shows the Load tab for creating a test.

  6. (Optional) On the Test criteria tab, configure criteria to determine when your load test should fail.

  7. (Optional) On the Monitoring tab, you can specify the Azure application components to capture server-side metrics for. For this quickstart, you're not testing an Azure-hosted application.

  8. Select Review + create. Review all settings, and then select Create to create the load test.

    Screenshot that shows the tab for reviewing and creating a test.

Note

You can update the test configuration at any time, for example to upload a different JMX file. Choose your test in the list of tests, and then select Edit.

Run the load test

In this section, you'll run the load test that you just created. If you selected the Run test after creation checkbox when you created the test, you can skip to View the load test results.

  1. Go to your Load Testing resource, select Tests from the left pane, and then select the test that you created.

    Screenshot that shows the list of load tests.

  2. On the test details page, select Run or Run test. Then, select Run on the Run test confirmation pane to start the load test.

    Screenshot that shows the run confirmation page.

    Tip

    You can stop a load test at any time from the Azure portal.

View the test results

While the load test is running, Azure Load Testing captures both client-side metrics and server-side metrics. In this section, you'll use the dashboard to monitor the client-side metrics.

  1. Go to the page that shows test details. Select the most recent test run.

    Screenshot that shows the list of test runs.

    You can see the streaming client-side metrics while the test is running. By default, the data refreshes every five seconds.

    Screenshot that shows results of the load test.

  2. Optionally, change the display filters to view a specific time range, result percentile, or error type.

    Screenshot that shows the filter criteria for the results of a load test.

Clean up resources

Important

You can reuse the Azure Load Testing resource that you created for other Azure Load Testing tutorials and how-to articles.

If you don't plan to use any of the resources that you created, delete them so you don't incur any further charges. If you've deployed the sample application in a different resource group, you might want to repeat the following steps.

To delete resources by using the Azure portal:

  1. Select the menu button in the upper-left corner, and then select Resource groups.

  2. From the list, select the resource group that you created.

  3. Select Delete resource group. Screenshot of the selections to delete a resource group in the Azure portal.

  4. Enter the resource group name. Then select Delete.

To delete resources by using the Azure CLI, enter the following command:

az group delete --name <yourresourcegroup>

Remember, deleting the resource group deletes all of the resources within it.

Next steps

You now have an Azure Load Testing resource, which you used to load test an external website.

You can reuse this resource to learn how to identify performance bottlenecks in an Azure-hosted application by using server-side metrics.