Configuring Windows Azure to Store Diagnostic Information
The Cloud Zone is brought to you in partnership with Iron.io. Discover how Microservices have transformed the way developers are building and deploying applications in the era of modern cloud infrastructure.
I was recently deploying a Windows Azure project where I used a different Windows Azure storage account for diagnostic data than for application data. After publishing the project to Windows Azure I noticed the diagnostic data wasn’t showing up as expected – there was nothing in the storage account I set up to collect diagnostic data. I checked the storage account for the application, and the diagnostic data was being collected there.
Well, that’s odd. I checked the value of the ‘Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString’ connection string, and sure enough it was set to the storage account for the application, not the account I set for diagnostic data.
I had set the diagnostic connection string to use the ’findabathroomdiag’ storage account.
<Role name="FindABathroom.Web"> <Instances count="2" /> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=findabathroomdiag;AccountKey=b" /> <Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=findabathroom;AccountKey=a"/> </ConfigurationSettings> </Role>
I would then publish the project using the publishing wizard in Visual Studio. In this wizard I would set the storage account to publish to ‘findabathroom’, the storage account for the application.
Looking at the ServiceConfiguration.cscfg file in the Windows Azure management portal I noticed the ‘Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString’ connection string was set to use ‘findabathroom’, and not ‘findabathroomdiag’ as I had expected.
What? Somebody’s playing tricks on me!
No tricks. I had forgotten about a change made to the Windows Azure tools for Visual Studio. If you open up the properties for your Windows Azure role, go to the Configuration tab. In the Diagnostics area you’ll find the “Use publish storage account as connection string when you publish to Windows Azure” check box. This option is checked by default!
This little check box setting will cause Visual Studio to change your diagnostics connection string to match the connection string used during publishing of the application.
If you don’t want Visual Studio to change your diagnostics connection string, then be sure to uncheck that box!