<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel Edwards</title>
    <description>The latest articles on DEV Community by Daniel Edwards (@dantheman999301).</description>
    <link>https://dev.to/dantheman999301</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F228825%2Faf454210-3e44-4da1-ad29-b6dec3822bb2.png</url>
      <title>DEV Community: Daniel Edwards</title>
      <link>https://dev.to/dantheman999301</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dantheman999301"/>
    <language>en</language>
    <item>
      <title>Running Gatling in Azure Container Instances Part 2 - Adding an API to control Gatling</title>
      <dc:creator>Daniel Edwards</dc:creator>
      <pubDate>Mon, 23 Sep 2019 11:38:41 +0000</pubDate>
      <link>https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-part-2-adding-an-api-to-control-gatling-3b1o</link>
      <guid>https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-part-2-adding-an-api-to-control-gatling-3b1o</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-2i59"&gt;Part 1 - Getting Gatling to run in Azure&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the last post, I went over a way to run Gatling in Azure Container Instances by mounting certain Azure Storage and editing configuration files. It was a somewhat hacky way to get it running and could certainly improved.&lt;/p&gt;

&lt;p&gt;It this article I will go into one way of automating it - adding an ASP.NET API on top.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step one - Creating a custom Docker runtime container
&lt;/h1&gt;

&lt;p&gt;The first step was to take the original Gatling docker container (&lt;a href="https://github.com/denvazh/gatling/blob/master/3.0.3/Dockerfile" rel="noopener noreferrer"&gt;denvazh/gatling&lt;/a&gt;) and use it as a base to create an image that has the dotnet dependencies baked in. &lt;/p&gt;

&lt;p&gt;This was a fairly simple process of adding the parts from the &lt;a href="https://github.com/dotnet/dotnet-docker/blob/master/2.2/runtime-deps/alpine3.8/amd64/Dockerfile" rel="noopener noreferrer"&gt;runtime-deps&lt;/a&gt; image and then adding on the parts needed for &lt;a href="https://github.com/dotnet/dotnet-docker/blob/master/2.2/aspnet/alpine3.8/amd64/Dockerfile" rel="noopener noreferrer"&gt;ASP.NET to run&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You end up with this dockerfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM denvazh/gatling:3.0.3

RUN apk add --no-cache \
        ca-certificates \
        \
        # .NET Core dependencies
        krb5-libs \
        libgcc \
        libintl \
        libssl1.1 \
        libstdc++ \
        lttng-ust \
        tzdata \
        userspace-rcu \
        zlib

# Configure web servers to bind to port 80 when present
ENV ASPNETCORE_URLS=http://+:80 \
    # Enable detection of running in a container
    DOTNET_RUNNING_IN_CONTAINER=true \
    # Set the invariant mode since icu_libs isn't included (see https://github.com/dotnet/announcements/issues/20)
    DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

# Install ASP.NET Core
ENV ASPNETCORE_VERSION 2.2.7

RUN wget -O aspnetcore.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/$ASPNETCORE_VERSION/aspnetcore-runtime-$ASPNETCORE_VERSION-linux-musl-x64.tar.gz \
    &amp;amp;&amp;amp; aspnetcore_sha512='d3c1cc27998fc8e45fbf0c652a8d8694e999a3cd5909f83fb11b1e5cf713b93f4e7614c4b74c92d6c04f0b0759373b6b6ff7218d9d143d36bb9b261ef8161574' \
    &amp;amp;&amp;amp; echo "$aspnetcore_sha512  aspnetcore.tar.gz" | sha512sum -c - \
    &amp;amp;&amp;amp; mkdir -p /usr/share/dotnet \
    &amp;amp;&amp;amp; tar -zxf aspnetcore.tar.gz -C /usr/share/dotnet \
    &amp;amp;&amp;amp; rm aspnetcore.tar.gz \
    &amp;amp;&amp;amp; ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I currently have this published on &lt;a href="https://hub.docker.com/r/dantheman999/gatling-aspnet" rel="noopener noreferrer"&gt;dockerhub here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With that made we have our runtime image.&lt;/p&gt;
&lt;h1&gt;
  
  
  Step two - Creating the API
&lt;/h1&gt;

&lt;p&gt;Visual Studio comes with some decent Docker templates already, so I started with a blank API with docker support. After that's spun up, the only change I needed to make in the dockerfile it created was changing the base to my own.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM dantheman999/gatling-aspnet AS base # Change the base image
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY ["Gatling.Runner.csproj", ""]
RUN dotnet restore "./Gatling.Runner.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Gatling.Runner.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Gatling.Runner.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Gatling.Runner.dll"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then it was a case of creating the API itself. There were two approaches I was considering for this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Continuing on with my original plan, mounting Azure Storage when the container is created, leaving the possibility of it being shared across multiple containers.&lt;/li&gt;
&lt;li&gt;Adding the simulation into the container directly when starting a new test.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I ended up opting for option 2. It gives much more flexibility, for example you could have the container running whilst you run multiple different tests before tearing it down, or having tests running concurrently if you so desired.&lt;/p&gt;

&lt;p&gt;Below I'm going to walk through some of the code used to get this to work. You can either follow it along or have a little look around the repo.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/deadwards90" rel="noopener noreferrer"&gt;
        deadwards90
      &lt;/a&gt; / &lt;a href="https://github.com/deadwards90/Gatling.Runner" rel="noopener noreferrer"&gt;
        Gatling.Runner
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="MD"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Azure + Gatling - Running Gatling in the Cloud&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;The projects in the repo contain applications that help to run Gatling in an automated fashion in Azure.&lt;/p&gt;

&lt;p&gt;Currently there is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;base-image&lt;/code&gt;: The folder containing a Gatling Docker container that can also run .NET Core applications.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/Gatling.Runner&lt;/code&gt;: An API for running Gatling tests on a machine. Combined with the Gatling container above this allows remote running of Gatling tests in the Cloud.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/Gatling.Orchestrator&lt;/code&gt;: A Durable Function for orchestrating running Gatling tests across multiple Azure Container Instances with returns a single combined result.&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/deadwards90/Gatling.Runner" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h3&gt;
  
  
  The Controller (GatlingController.cs)
&lt;/h3&gt;

&lt;p&gt;The controller has 3 endpoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Start&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;StartAsync&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GetResults&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Start&lt;/code&gt; will take a test upload, store the files, run the test and return the results as one operation. &lt;code&gt;StartAsync&lt;/code&gt; and &lt;code&gt;GetResults&lt;/code&gt; do the same thing except &lt;code&gt;StartAsync&lt;/code&gt; will just return the &lt;code&gt;runId&lt;/code&gt; which can be used to query the results whilst the test is running in the background.&lt;/p&gt;

&lt;p&gt;Starting with the simplest method, &lt;code&gt;Start&lt;/code&gt;.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It is basically as explained above. We take the runId and create the folders necessary for Gatling to run. If the full report is required, then it will run the simulation and return a zip of the result, otherwise it will return the results of the run which is just the console output created by Gatling when it runs.&lt;/p&gt;

&lt;p&gt;Then we have the async version of this which is a little more complicated.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It takes the same format of request as &lt;code&gt;Start&lt;/code&gt;, but all it does is creates the folders and then queues up a job to be run asynchronously in the background, before returning the runId location.&lt;/p&gt;

&lt;p&gt;You could then poll the &lt;code&gt;GetResults&lt;/code&gt; endpoint for the run, which will return the zipped up Gatling results when completed (or return that there was a failure).&lt;/p&gt;

&lt;h3&gt;
  
  
  The Services
&lt;/h3&gt;

&lt;h4&gt;
  
  
  File Service (FileService.cs)
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Two very simple methods here, one for creating the necessary folder structure for Gatling to run and the other that creates a &lt;code&gt;FileStream&lt;/code&gt; to send back the zipped results folder.&lt;/p&gt;

&lt;p&gt;One thing to notice here is that it reads a file out of the zip provided through the controller called &lt;code&gt;run.json&lt;/code&gt;. All this has in it at the moment is the name of the simulation to run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"SimulationClassName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"apimsimulations.ApiMSimulation"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Gatling Service (GatlingService.cs)
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;The only job this has so far is to run the a test given the &lt;code&gt;RunSettings&lt;/code&gt; from the &lt;code&gt;FileService&lt;/code&gt; is to run that against Gatling, and that is done by just running the process and waiting for it to finish. You can see what each of the command line arguments for Gatling does &lt;a href="https://gatling.io/docs/3.0/general/configuration/#command-line-options" rel="noopener noreferrer"&gt;here&lt;/a&gt;, but for the most part we are just telling it where things are and what simulation we wish to run.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Background Services
&lt;/h4&gt;

&lt;p&gt;For the asynchronous methods, I took the &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.2&amp;amp;tabs=visual-studio#queued-background-tasks" rel="noopener noreferrer"&gt;skeleton of the code from the ASP.NET Core documentation&lt;/a&gt; and changed a few pieces of it. The main change was to add a &lt;code&gt;jobId&lt;/code&gt; to an item when queued which had an accompanying state. When the job was finished, its state was updated for the &lt;code&gt;GetResults&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;h5&gt;
  
  
  Job Status Service (JobStatusService.cs)
&lt;/h5&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This service keeps track of the state for a run. Obviously not ideal using a &lt;code&gt;ConcurrentDictionary&lt;/code&gt; as a data store but given the container should be spun up for one or two jobs before being destroyed, it works fine.&lt;/p&gt;

&lt;h5&gt;
  
  
  Background Task Queue (BackgroundTaskQueue.cs)
&lt;/h5&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This is pretty much a copy of the documentation example, except we now have it taking a Tuple with the job id and job to run. When the job gets queued, it's State is set to started which is a little wrong in all honesty as it's only been queued up at this point.&lt;/p&gt;

&lt;h5&gt;
  
  
  Queue Hosted Service (QueueHostedService.cs)
&lt;/h5&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Finally the task is dequeued here, and run. Once finished its &lt;code&gt;State&lt;/code&gt; is updated so that the controller knows it can pick up the results.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 3 - Run a request
&lt;/h1&gt;

&lt;p&gt;With all of this set up, we can now run a test!&lt;/p&gt;

&lt;p&gt;Create a zip with your simulation (and resources if you have them) in the same format as it would be in the Gatling folders, and also your &lt;code&gt;run.json&lt;/code&gt; that was explained earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff04jis3xka0k82gckpvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff04jis3xka0k82gckpvs.png" alt="test.zip layout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Send a request to the API on &lt;code&gt;api/gatling/start/{uuid}?returnReport=true&lt;/code&gt; (easiest just to start with the synchronous method) with your zip file attached. The request will take as long as your simulation is, plus around 10 seconds for the initial start up time.&lt;/p&gt;

&lt;p&gt;And that's it 🎉 You now have a remotely controlled Gatling that can be hosted in Azure once it is built.&lt;/p&gt;

&lt;p&gt;If you just want to directly play around with container without compiling it yourself, you can grab it &lt;a href="https://hub.docker.com/r/dantheman999/gatling.runner" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next steps
&lt;/h1&gt;

&lt;p&gt;In part three, I will be creating a wrapper around this in Azure that will&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a set number of Azure Container Instances of the container, possibly in mulitple regions&lt;/li&gt;
&lt;li&gt;Set them all to run a test using a similar API as the one in the container (with more checking that the zip looks "correct").&lt;/li&gt;
&lt;li&gt;Wait for them all to finish and get all the &lt;code&gt;simulation.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Merge the log files and create a master report.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>gatling</category>
      <category>azure</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Running Gatling in Azure Container Instances Part 1 - Getting Gatling to run in Azure</title>
      <dc:creator>Daniel Edwards</dc:creator>
      <pubDate>Fri, 13 Sep 2019 07:42:27 +0000</pubDate>
      <link>https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-2i59</link>
      <guid>https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-2i59</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/dantheman999301/running-gatling-in-azure-container-instances-part-2-adding-an-api-to-control-gatling-3b1o"&gt;Part 2 - Adding an API to control Gatling&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am going to preface this by saying that I know rather little about Gatling overall so this was a best effort to get this at least running. I could not find any other tutorials on how to have Gatling running at all in Azure.&lt;/p&gt;

&lt;p&gt;I will also assume if you are reading this you have at least some knowledge of Azure and the Azure CLI. &lt;/p&gt;

&lt;h1&gt;
  
  
  Setting Up
&lt;/h1&gt;

&lt;p&gt;If you are unaware of what Azure Container Instances are, I would suggest having a &lt;a href="https://azure.microsoft.com/en-gb/services/container-instances/" rel="noopener noreferrer"&gt;quick read through this page&lt;/a&gt;. Essentially they can provide a short lived container for a very cheap price.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the Azure File Shares
&lt;/h2&gt;

&lt;p&gt;The first thing you're going to need is an Azure Storage Account which can be either created through the portal or through a small script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az storage account create \
    --resource-group gatling \
    --name stgatling \
    --location uksouth \
    --sku Standard_LRS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will then need a three file shares, &lt;code&gt;conf&lt;/code&gt;, &lt;code&gt;user-files&lt;/code&gt; and &lt;code&gt;results&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az storage share create --name conf --account-name stgatling 

az storage share create --name user-files --account-name stgatling 

az storage share create --name results --account-name stgatling 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally you're going to want to grab the account key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az storage account keys list --resource-group gatling --account-name stgatling --query "[0].value" --output tsv

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course you can also grab this very simply through the portal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F48yand5qap18wsltiub4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F48yand5qap18wsltiub4.png" alt="Getting account keys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the Container Instance
&lt;/h2&gt;

&lt;p&gt;Now you're going to want to create a YAML file to deploy the Gatling container. To do this we'll be using the container groups template but just deploying the one container. Below is an example that should work, you will just need to insert your storage key into the the &lt;code&gt;volumes&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: '2018-10-01'
location: uksouth
name: gatling-aci
properties:
  containers:
    - name: gatling
      properties:
        environmentVariables: []
        image: denvazh/gatling
        ports:
          - port: 80
        resources:
          requests:
            cpu: 1.0
            memoryInGB: 1.5
        volumeMounts:
          - mountPath: /opt/gatling/conf
            name: conf
          - mountPath: /opt/gatling/user-files
            name: user-files
          - mountPath: /opt/gatling/results
            name: results
  osType: Linux
  restartPolicy: Never
  ipAddress:
    type: Public
    ports:
      - port: 80
    dnsNameLabel: gatling-test
  volumes:
    - name: conf
      azureFile:
        sharename: conf
        storageAccountName: stgatling
        storageAccountKey: &amp;lt;insert-storage-key-here&amp;gt;
    - name: user-files
      azureFile:
        sharename: user-files
        storageAccountName: stgatling
        storageAccountKey: &amp;lt;insert-storage-key-here&amp;gt;
    - name: results
      azureFile:
        sharename: results
        storageAccountName: stgatling
        storageAccountKey: &amp;lt;insert-storage-key-here&amp;gt;

tags: {}
type: Microsoft.ContainerInstance/containerGroups

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create and start your container group. What should happen at this point is Gatling will run but then stop very quickly as there are no simulations to run. &lt;/p&gt;

&lt;h2&gt;
  
  
  Uploading the configuration
&lt;/h2&gt;

&lt;p&gt;So we need to go ahead and upload those to the file share &lt;code&gt;user-files&lt;/code&gt;. There are a number of ways you can go about this depending on what OS you are using, starting off with mounting the Azure File Shares we made earlier:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Windows - &lt;a href="https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux - &lt;a href="https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-linux" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-linux&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;macOS - &lt;a href="https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-mac" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-mac&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alternatively you could upload the files through &lt;a href="https://azure.microsoft.com/en-us/features/storage-explorer/" rel="noopener noreferrer"&gt;Azure Storage Explorer&lt;/a&gt; or through the portal.&lt;/p&gt;

&lt;p&gt;Our folder had a &lt;code&gt;simulations&lt;/code&gt; and &lt;code&gt;resources&lt;/code&gt; folder directly under it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnic2k6yceeafabq488vk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnic2k6yceeafabq488vk.png" alt="Folder layout example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Ignore the bad naming)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Finally, we're going to want to take the default &lt;a href="https://github.com/gatling/gatling/blob/master/gatling-core/src/main/resources/gatling-defaults.conf" rel="noopener noreferrer"&gt;gatling.conf&lt;/a&gt; and edit two lines.&lt;/p&gt;

&lt;p&gt;First one to edit is &lt;code&gt;runDescription&lt;/code&gt; to be anything that isn't a blank string. Whatever your run is going to be!&lt;/p&gt;

&lt;p&gt;Secondly, edit &lt;code&gt;simulationClass&lt;/code&gt; to be the fully qualified class name of simulation you wish to run. For us this was &lt;code&gt;apimsimulations.ApiMSimulation&lt;/code&gt; (we were testing out an API Management integration).&lt;/p&gt;

&lt;p&gt;Now upload that into the &lt;code&gt;conf&lt;/code&gt; file share.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the simulation
&lt;/h2&gt;

&lt;p&gt;You're now all set to run the simulation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az container start \
   --resource-group gatling
   --name gatling-aci
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Container start up should be fairly quick and it will compile your simulation and run it. The easiest way to see what it is doing is just to check the logs through the portal, or you can get these from the cli.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az container logs \
   --resource-group gatling
   --name gatling-aci
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the end it should say that it has generated the report(s)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reports generated in 2s.
Please open the following file: /opt/gatling/results/apimsimulation-20190912115211503/index.html
Global: count of failed requests is 0.0 : true
Global: mean of response time is less than 500.0 : true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then you can retrieve those from the file share using the same method as you did to upload the files.&lt;/p&gt;

&lt;h2&gt;
  
  
  TODO
&lt;/h2&gt;

&lt;p&gt;There are quite a few things I'd like to work out how to do, some of which I think would be fairly simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running Gatling in non-interactive mode. This should just be editing the startup command (entrypoint) for the container instance to include the simulation you wish to run. This could allow for a level of automation...&lt;/li&gt;
&lt;li&gt;Working out how to get the container to stop once it has finished running.&lt;/li&gt;
&lt;li&gt;Automating this whole process. You could use an Azure Function to create a container on demand, mounting onto the file shares. It then would just need to specify a simulation to run in non-interactive mode, wait for completion and stop  / delete the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a first attempt though, pretty happy with how far I managed to get it. Little cheaper and somewhat easier than spinning up a whole VM to do this! &lt;/p&gt;

</description>
      <category>gatling</category>
      <category>azure</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
