Skip to content

Microsoft Azure

Microsoft Azure

Microsoft Azure is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

The documentation below explains how to configure Microsoft Azure cloud provider.

Azure Setup

Prerequisites

Before trying to configure Microsoft Azure, make sure you have:

  • A Microsoft Azure Account with a valid subscription.

Resource Group

Microsoft Azure Resource Group

The resource group is a container that holds related Azure resources.

How to create a resource group

  • Go to Resource Groups,
  • Click on Add,
  • In Basics section, select the subscription and enter octoperf in Resource group name,
  • Select the region where the group should be located (Here in (Europe) France Central),
  • Click on Review + Create.

The resource group must be named octoperf (all lowercase characters).

Enterprise Application

The next step is to create Azure application credentials so OctoPerf can programmatically start and stop virtual machines on Microsoft Azure. Please see How to Use Azure to create an application that can access resources.

Basically, you need to:

  • Create an Azure Application Registration in App Registrations with the name you want (Example: OctoPerf), Application type Web app / API and no sign-on URL needed,
  • Assign the newly created application a Contributor or equivalent so the application can create, start and stop virtual machines,
  • Create an Application Client Secret later used to authenticate from OctoPerf.

Once done, please keep a-side:

  • (Client) Application Id,
  • Client Secret,
  • Tenant Id,
  • And subscription Id.

Those information are needed to allow OctoPerf to connect to your Microsoft Azure account.

Virtual Networks

Microsoft Azure Virtual Network

A virtual network for each Azure Location is required. Virtual machines spinned up by octoperf are configured with this virtual network.

Creating a virtual network

  • Go to Virtual Networks,
  • Click on + Add,
  • Name the virtual network with octoperf- prefix followed by the location id. Example: octoperf-francecentral in France Central,
  • Enter Address Space. Example: 10.1.0.0/16,
  • Select octoperf resource group,
  • Select the location where to create the virtual network. Example: France Central,
  • Enter the Address Range. Example: 10.1.0.0/24,
  • DDos Protection set at your convenience. Defaults to Basic,
  • Service Endpoints and Firewall can be left as Disabled.

Make sure the name of the virtual network starts with octoperf-. Create a virtual network per location, preferrably named octoperf-location (replace location by the actual location).

Microsoft Azure Shared Image Gallery

Our Azure integration uses Shared Image Galleries as virtual machine base image.

Create Shared Image Gallery

  • In Azure Portal, Open Shared Image Galleries,
  • Create a shared image gallery whose name starts with OctoPerf (case-insensitive).

The next step is to create a shared image definition.

Create Image Definition

  • Select the newly created image gallery (named OctoPerfGallery in our case),
  • Click on Add new image definition,
  • In name, prefix it with OctoPerf (cas-insensitive),
  • Enter all settings being asked such as Operating System, VM Generation (usually Gen 1), Publisher, SKU and more.

The next step is to create the first image version. The best tool to do this is Packer.

Create an Image using Packer

  • Here is an example packer script azure.json to build an image with Docker and octoperf images preinstalled:
{
  "_comment": "Azure Build",

  "builders": [
    {
      "type": "azure-arm",
      "name": "azure",
      "client_id": "{{user `azure_client_id`}}",
      "client_secret": "{{user `azure_client_secret`}}",
      "subscription_id": "{{user `azure_subscription_id`}}",

      "os_type": "Linux",
      "image_publisher": "Canonical",
      "image_offer": "UbuntuServer",
      "image_sku": "18.04-LTS",
      "location": "francecentral",

      "ssh_username": "ubuntu",
      "shared_image_gallery_destination": {
        "resource_group": "octoperf",
        "gallery_name": "{{user `azure_gallery_name`}}",
        "image_name": "{{user `azure_gallery_image`}}",
        "image_version": "{{user `azure_image_version`}}",
        "replication_regions": [
        ]
      },
      "managed_image_name": "octoperf-{{timestamp}}",
      "managed_image_resource_group_name": "octoperf",
      "managed_image_zone_resilient": true
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "wget -qO- https://get.docker.com/ | sh",
        "sudo usermod -aG docker {{user `ssh_username`}}",
        "sudo docker pull {{user `octoperf_agent`}}",
        "sudo docker pull {{user `jmeter_standard`}}",
        "sudo docker pull {{user `jmeter_webdriver`}}"
      ]
    },
    {
      "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
      "inline": [
        "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
      ],
      "inline_shebang": "/bin/sh -x",
      "type": "shell"
    }],

  "post-processors": [
    {
      "type": "manifest",
      "output": "azure-manifest.json",
      "strip_path": true
    }
  ]
}

This is the variables file vars.json:

{
  "azure_image_version": "xx.x.x",
  "azure_client_id": "YOUR_CLIENT_ID",
  "azure_client_secret": "YOUR_CLIENT_SECRET",
  "azure_subscription_id": "YOUR_SUBSCRIPTION_ID",
  "azure_tenant_id": "YOUR_TENANT_ID",
  "azure_gallery_name": "YOUR_GALLERY_NAME",
  "azure_gallery_image": "YOUR_GALLERY_IMAGE_NAME",

  "ssh_username": "ubuntu",
  "jmeter_standard": "octoperf/jmeter-standard:xx.x.x",
  "jmeter_webdriver": "octoperf/jmeter-webdriver:xx.x.x",
  "octoperf_agent": "octoperf/docker-agent:xx.x.x"
}

Make sure to replace xx.x.x by the latest version by taking a look at the release notes.

To run the script:

packer build -var-file=vars.json azure.json

Microsoft Azure Shared Image Gallery Version

Once the build is finished, it should have created an image with docker and OctoPerf docker images preinstalled. This image is not replicated by default. Fill replicated_regions to automatically replicate the image in all the specified regions.

Azure Provider

Azure Settings

Microsoft Azure Provider

The final step is to create the Microsoft Azure provider from OctoPerf UI:

  • Click on your account menu, then Private Hosts,
  • Click on + Add Provider button, then Microsoft Azure,
  • Enter the relevant information being asked.

Azure requires the following settings:

  • Application (client) ID: id of the application,
  • Client Secret: the secret password generated when creating the Azure enterprise application,
  • Directory (tenant) ID: tenant ID,
  • Subscription ID: id of the subscription to use,
  • Environment: Azure by default,
  • Resource Group: octoperf by default,
  • SSH: virtual machines created by OctoPerf can be sshed using the settings provided here,
  • SSH User: username to use to ssh into the virtual machine instance from outside,
  • SSH Password or Public Key: Either a password or an SSH public key.

Instance Types

The following Instances are available:

  • SMALL: cloud instance with about 2GB RAM, (STANDARD_B1MS used)
  • MEDIUM: cloud instance with about 4GB RAM, (STANDARD_B2S used)
  • LARGE: cloud instance with about 8GB RAM, (STANDARD_D2_V3 used)
  • XLARGE: cloud instance with about 16GB RAM. (STANDARD_D4_V3 used)

Select the instance which suits your needs. Smaller instances can simulate less concurrent users.

Shutdown Policy

The shutdown policy specifies the minimum amount of time a cloud instance should be running before being eligible for automatic shutdown.

Example: shutdown specified after 55min.

Info

Only idle machines (not running load tests) are eligible for shutdown. OctoPerf waits until the test ends before shutting the instance down.

Memory Usage

Memory Usage

These settings are the same as for the self-hosted provider.

Regions

Microsoft Azure Provider Regions

OctoPerf automatically detected your Azure locations based on a naming convention. OctoPerf expects that you have in each location you want to use:

  • Name: name of the region,
  • Gallery: name of the shared image gallery,
  • Image: name of the image within the shared image gallery to use,
  • Version: version of the shared image to use. if none specified, the first image available is used,
  • Network name: a virtual network prefixed with octoperf- within the same region,
  • Network Subnet: a subnet with the name of your choice, usually default (must exist within the virtual network).

If no location is being pre-configured, make sure you followed all the steps in Azure Setup prior to trying to configure Azure in OctoPerf.

Static IPs

Microsoft Azure Provider Static IPs

Microsoft Azure Public IPs can be allocated through the UI. When a virtual machine is started, the public IP within the same region is automatically assigned to it.