Azure Diagnostics Configuration

Recently I was working on a task where I had to update the azure applications from Azure v2.1 to v2.7. I made the required changes to the application and when I tried to deploy the application on the Azure I faced many challenges and Issues. I will try and put as many as possible issues I faced during this transition phase, in this and coming write up’s to keep a log for myself and for others too.

During deployment I faced an error stating:

The element StorageAccount doesn’t match the storage account name provided in the cmdlet arguments. It is recommended to not use the element StorageAccount as it is automatically set by the cmdlet.

Initially I went with the words from the error message and removed the –StorageContext from my below command.

Write-Verbose 'Start Set-AzureServiceDiagnosticsExtension'

Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $wadConfig-ServiceName $AzureServiceName -Slot $AzureSlot  -Role $role

To my surprise it didn’t threw any error but the code did not completed the deployment also. I waited for more than two hours but the Azure Management Console still showed “In Transition“ state.

Now it was clear that the error message is not depicting the actual problem. I started looking into the changes I made during the code transition from v2.1 to v2.7. After going through many files and many lines of code, I found out that the issue was because I was having an empty Storage Account tag in the Diagnostics Configuration file(.wadcfgx).

<StorageAccount />

I should not say this was the only reason which caused the error. In fact, in my .cscfg file I did not introduced the AccountName under diagnostics connection string. And as per the MSDN,

  • If a diagnostics connection string is specified in the .cscfg file, Visual Studio uses it to configure the diagnostics extension when publishing, and when generating the public configuration xml files during packaging.
  • If no diagnostics connection string is specified in the .cscfg file, then Visual Studio falls back to using the storage account specified in the .wadcfgx file to configure the diagnostics extension when publishing, and generating the public configuration xml files when packaging.
  • The diagnostics connection string in the .cscfg file takes precedence over the storage account in the .wadcfgx file. If a diagnostics connection string is specified in the .cscfg file, then Visual Studio uses that and ignores the storage account in .wadcfgx.

So, to fix the bug I made few changes to my code:

  • First, I introduced the storage account name in the connection string of the “.cscfg” file.
    <ConfigurationSettings>
    <Setting
    name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"
    value="DefaultEndpointsProtocol=https;
    AccountName=TestAccount;
    AccountKey=HUKNuwWdLOKM1dOhFzqLZrUcHvtAbg==" />
  • Second, I removed the <StorageAccount /> tag from my configuration file

After making the above two changes everything started working fine and my changes got deployed.

Advertisements