AzureFiddlerCore allows any .net application running in Windows Azure to capture HTTP traffic that the application produces, and automatically store it with BlobStorage.

It is the result of an amalgamation of two of my passions, the power and scalability of Windows Azure with the insight possible through using Fiddler. With version 1.3 of the Azure SDK, it is now possible to remote desktop onto any of your instances, meaning you can download and install Fiddler on the instances. It is possible, but in practise it is a bit tricky. The instances all have hard security enabled so downloading Fiddler requires messing around with trusted sites (and remembering to set the trusted site for the download to GetFiddler.com rather than fiddler2.com!). Additionally, you are installing a HTTP proxy onto a machine, which could negatively effect the performance of the instance should you forget to disable it afterwards. Then you have the problem of getting the traces off the instance in order to debug them, which may be a little tricky.

AzureFiddlerCore shortcuts these problems by embedding a core version of Fiddler directly into your Azure application, that writes its traces directly to BlobStorage. You simply startup the proxy, passing it a little information about storage account, and then for any particular web requests you are interested in you simply get a WebProxy class from AzureFiddlerCore and AzureFiddlerCore will handle logging the information to the specified storage account.

Setup

AzureFiddlerCoreLib.AzureFiddlerCore.Connect(storageAccount, filterList, localResource);

Unlike Fiddler’s normal operation, the default behaviour of AzureFiddlerCore is to only capture those requests that you manually pass through to it. Furthermore, you can specify a list of hostname domains to allow capture for, and thus anything not in this list is ignored. I call this an entropy reduction approach – only those requests you want to trace are logged.

using (var wc = new WebClient())
{
wc.Headers.Add(HttpRequestHeader.UserAgent, "AzureFiddlerCore.Demo");
var _proxy = AzureFiddlerCoreLib.AzureFiddlerCore.GetProxy();

if (_proxy != null)
{
wc.Proxy = _proxy;
}

// snip

Output

Once you have set up your capture and made some HTTP requests from within your application, you will find that containers are created for you in BlobStorage for the account you specified. The below shows these containers, using the default container naming policy (which you can change to supply your own container name). This is made up of “afcsaz-” a prefix short for AzureFiddlerCore Session Archive Zip, the Tick count (to make a unique name) and the name of the role that did the logging.
Azure Fiddler Core output

Azure Fiddler Core output

Opening up one of these containers shows how you can get at the Fiddler output – the SAZ files in this container can be downloaded and opened in the full Fiddler desktop client, allow you to inspect the remote HTTP request/responses.
Container contents

Container contents

A session in Fiddler Desktop client, that was captured in Azure

A session in Fiddler Desktop client, that was captured in Azure

Acknowledgements

This project wouldn’t have been possible without Eric Lawrence, the creator of Fiddler. In addition, he supplied the technology required to export to a SAZ archive (http://fiddler.wikidot.com/saz-files). In the implementation of SAZ creation, the software usesĀ DotNetZip, so I’d like to thank them for their reliable software.

Source Code

If you are interested in what this can provide, I suggest you download the source code, which contains an example project. It is ready to run on DevFabric, but if you update the storage account details you will be able to get it to run in Azure with no problems.

The source code for this project is available on CodePlex atĀ http://azurefiddlercore.codeplex.com/

About these ads