Missing IIS log files in Azure Cloud Service

I recently upgraded a Azure Cloud Service from the 2.3 SDK to the 2.5 SDK. I keep the IIS log files for analysis but after the upgrade I noticed that I stopped getting the files uploaded to the storage account.

Digging around I found this was an issue with the Azure 2.5 SDK and that the workaround is to modify the OnStart method in your WebRole.cs file. This requires a restart of your app before you’ll start seeing the IIS log files copied over to your storage account.

One thing that I didn’t expect is that the Azure Diagnostics only copied newer files. I guess this makes sense, so I went digging around for a way to copy the older files to the storage account.

Here’s what I came up with.

Connect via Remote Desktop to the Web Role in Server Explorer.

Open a Poweshell prompt and download AzCopy.

PS> invoke-webrequest http://aka.ms/downloadazcopy -OutFile AzCopy.msi

Run the AzCopy.msi installer and open the Microsoft Azure Storage Command Line. This opens a command window with the path to the azcopy executable already in the path.

Now before I could go further I wanted to place the log files in the same directory structure that Azure Diagnostics already supports. Querying the storage account I see they are located in the following location:


But where are the files located on the Azure Cloud virtual machine? Digging around I see that the log files are stored at the location

c:\Resource\Directory\<deployment_id>.<site_name>.DiagnosticStore\Web directory.

To make this easier to see on the command line, I created a configuration file with all the arguments I needed to pass to AzCopy. Here’s my configuration file (excluding private information)

/DestKey:<storage account key>

Knowing this I could now use AzCopy to copy the old IIS log files up to the storage account using the following AzCopy command.

AzCopy /@:copyfiles.cfg

After AzCopy was done copying the files, I repeated the same operations on the other nodes in the Azure Cloud Service and verified the files were there by using the BlobTransferUtility, that I use to copy the files locally.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: