Using advanced diagnostics to debug issues in Cloud Load Test.

Cloud Load Testing can be used for performance and load testing of your application by generating load from Azure. If you are new to Cloud Load Testing then the following links will help you:

It is often observed that debugging on cloud is a little difficult as the machines are not directly accessible to the user. It is not possible to collect logs or any other information from the test agents easily.

With advanced agent diagnostics feature customer will be able to collect logs from the test agents and download it from an Azure Blob and analyze the data.


Some scenarios where this feature is useful:

  1. My unit tests are failing on cloud and the test logs in Load test results  are not sufficient to debug the issue. In this scenario I can put trace statements in my unit-test for logging and analyze the UT failure with these trace logs.
  2. My test generates some files which are needed to understand the test output better. You can collect these files by just copying the files to the “Result Directory”.
  3. If I want to have detailed diagnostic to find networking bottlenecks using packet capture tools such as Wireshark. You can install WireShark as part of the Setup Script (Link ), redirect the logs to “Result Directory”. This feature will upload the files to blob from where I will be able to access them.


How to use trace logs in CLT for debugging ?

Using trace logs is as simple as writing any trace statement in your code.



 Trace.TraceInformation("Information :{0}", DateTime.UtcNow);

Trace.TraceWarning("Warning :{0}", DateTime.UtcNow);

Trace.TraceError("Error: {0}", DateTime.UtcNow);


These trace statements can be used in your UnitTest code, Load Test Plugin, WebTestPlugin code.

The trace logs will be available at the end of the run from the blob.

TraceFileName: Traces.log

 Right now we have enabled the trace logs at warning level.

You can contact the team if you want to get the level reset to some lower or higher value at


How to collect other files from test agent?

We have enabled files upload from testagent to Azure blob from a specific directory(ResultDirectory) on agent disk space.

The ResultDirectory is an environment variable which can be used in code/setup script/cleanup scripts.

You can drop the files you need from test agent to this directory and download it from blob.

These files will be available from blob as and when they are available on agent(with some latency)


How can you drop the files to the Result directory?

  1. You can do this in any of the places you have code, in webtest plugin, load test plugin or unittest.
  2. You can do this in setup script.
  3. You can install some debugging tools and redirect the logs to the resultdirectory.


Eg: You can use AddResultFile method of TestContext for adding results file to the blob as well:

 private TestContext _testContextInstance;
 public TestContext TestContext
get { return _testContextInstance; }
set { _testContextInstance = value; }
public void TestMethod()
var filePath = Path.Combine (TestContext.DeploymentDirectory, "File.txt");

   You can use the following code to copy files directly to result directory :

public void TestMethod()
var fileName = "File.txt";
var sourceLocation = TestContext.DeploymentDirectory;
var resultLocation = TestContext.ResultsDirectory;
var sourceFilePath = Path.Combine(sourceLocation, fileName);
var destinationFilePath = Path.Combine(resultLocation, fileName);
File.Copy(sourceLocation, destinationFilePath);

How can you access the collected files from blob? 

Using our Rest APIs

We have exposed the connection string of the blob location which contains diagnostic files using our Test Results API.

Link to our Test Results API Documentation:


GET https://{account}{testrunid}/results



"resultsUrl":"https://{serviceStore} 10296ab9ef56&sig=TFPOQOCQ8uNu2%2FYFrW4F%2BTeXiiPiAIlZPCI6jyi%2F5Dw%3D&se=2015-01-29T04%3A43%3A58Z",



"lastModifiedTime" : "2015-04-28T09:50:28Z"




The highlighted section are details required to download the diagnostics data.

  • diagnosticStoreConnectionString -> The connection string to the container which contains files
  • relativePathToDiagnosticFiles -> Relative path to the directory which contains diagnostic files
  • lastModifiedTime -> It shows the last modified time of the diagnostic folder. 

Link to Azure Blob documentation:

Using the above information, you can use below code for downloading the files from blob:

  public void DownloadFilesFromBlob()

var container = new CloudBlobContainer(diagnosticStoreConnectionString);
Microsoft.WindowsAzure.StorageClient.CloudBlobDirectory blobDirectory = container.GetDirectoryReference(relativePathToDiagnosticFiles);
var blobFiles = blobDirectory.ListBlobs(new BlobRequestOptions { UseFlatBlobListing = true }).ToList();

string dirPath = Path.GetTempPath();
dirPath = dirPath + "/diagnostics";

foreach (var listBlobItem in blobFiles)
var blob = (CloudBlob)listBlobItem;
var path = dirPath + "/" + Path.GetFileName(blob.Name);

Once the files are downloaded to your machine, you can analyze the files.


Important things to note:

  • Maximum of 100 MB size per agent data will be collected from result directory.
  • The contents of the resultdirectory are copied at regular intervals except for trace logs which are uploaded at the end of run.


Please contact team if you need the max limit per agent to be increased at

If you have a feature request for us or an improvement you’d like to see, please log them on our user voice site.

Hope the post helps in debugging your tests on CLT.