none
Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener

    Question

  • While using Windows Azure Table Storage in WCFService WebRole, tried to create CloudStorageAccount by the following way: storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("cloudStorageLocal")).

    From ServiceConfigurationLocal.cscfg file: <Setting name="cloudStorageLocal" value="UseDevelopmentStorage=true" /> (ServiceConfigurationCloud.cscfg have the same string)

    Get exception: 

    ConfigurationErrorsException "Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35."

    MSDN help says that 1) Visual Studio must be run as an administrator. 2) A role must be running under full trust (change the .NET trust level option to Full Trust).

    All Done!! But I still have the same exception...

    Now use CloudStorageAccount.DevelopmentStorage property to connect local storage and CloudStorageAccount.Parse("Connection String") to use Azure Storage - why these methods work? They don't use DiagnosticMonitorTraceListener? Help me, please!

    Saturday, November 24, 2012 12:58 PM

Answers

  • Are you using Storage Client Library 2.0? Please note that Windows Azure Diagnostics still make use of Storage Client Library 1.7. You can use both storage client library 1.7 and 2.0 together in the same project.

    Also there was a bug with storage client library 2.0.0 regarding CloudStorageAccount.Parse("UseDevelopmentStorage=true") which was fixed in version 2.0.1.

    Hope this helps.

    • Marked as answer by Kseniya-user Monday, November 26, 2012 5:10 PM
    Saturday, November 24, 2012 1:17 PM
  • But I relly don't understand, why there are two different namespaces Microsoft.WindowsAzure.Storage and Windows.WindowsAzure both included CloudStorageAccount Class

    What has happened is that storage team has released version 2.0 of the storage client library. Version 2.0 is significantly different than version 1.7 and a lot of refactoring has been done. With version 1.7, everything was either in Microsoft.WindowsAzure or Microsoft.WindowsAzure.StorageClient namespaces while in 2.0 they were in different namespaces. For example, in 1.7 CloudStorageAccount was in Microsoft.WindowsAzure namespace while in 2.0 it is in Microsoft.WindowsAzure.Storage namespace.

    Coming back to diagnostics, try the following code. I created a simple worker role project:

            public override void Run()
            {
                DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
                config.OverallQuotaInMB = 4096;
                config.Logs.BufferQuotaInMB = 512;
                config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
                //config.DiagnosticInfrastructureLogs.BufferQuotaInMB = 512;
                //config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
    
                // Apply the updated configuration to the diagnostic monitor.
                // The first parameter is for the connection string configuration setting.
                DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
                
                // This is a sample worker implementation. Replace with your logic.
                Trace.WriteLine("WorkerRole1 entry point called", "Information");
    
                while (true)
                {
                    Thread.Sleep(10000);
                    Trace.WriteLine("Working", "Information");
                }
            }
    

    This is how the configuration file looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceConfiguration serviceName="WindowsAzure5" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2012-10.1.8">
      <Role name="WorkerRole1">
        <Instances count="1" />
        <ConfigurationSettings>
          <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
        </ConfigurationSettings>
      </Role>
    </ServiceConfiguration>

    Hope this helps. 

     

    Monday, November 26, 2012 6:21 AM

All replies

  • Are you using Storage Client Library 2.0? Please note that Windows Azure Diagnostics still make use of Storage Client Library 1.7. You can use both storage client library 1.7 and 2.0 together in the same project.

    Also there was a bug with storage client library 2.0.0 regarding CloudStorageAccount.Parse("UseDevelopmentStorage=true") which was fixed in version 2.0.1.

    Hope this helps.

    • Marked as answer by Kseniya-user Monday, November 26, 2012 5:10 PM
    Saturday, November 24, 2012 1:17 PM
  • I've updated StorageClient through NuGet to brouse Microsoft.Data.OData.5.0.2 and now I have Microsoft.WindowsAzure.ConfigurationManager.1.7.0.3 and Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0 - which of them do I need to use? 

    I have Microsoft.WindowsAzure.StorageClient.dll ver. 1.7.0.0. and I added WindowsAzure.Storage.2.0.1.0 lib.

    Saturday, November 24, 2012 4:13 PM
  • Please ensure that as far as diagnostics is concerned, you make use of classes which are there in Storage Client library 1.7.0.0 and not 2.0.1. You can use Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0.

    so, the CloudStorageAccount in the following code:

    storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting("cloudStorageLocal")).
    Actually refers to Microsoft.WindowsAzure.CloudStorageAccount and not

    Microsoft.WindowsAzure.Storage.CloudStorageAccount.

    It would also help if you can copy the source of your role's OnStart() method (or the complete code for diagnostics initialization) here so that somebody can take a look.

    Hope this helps.


    Saturday, November 24, 2012 4:25 PM
  • Upps.. Actually it refers to Microsoft.WindowsAzure.Storage.CloudStorageAccount. But I relly don't understand, why there are two different namespaces Microsoft.WindowsAzure.Storage and Windows.WindowsAzure both included CloudStorageAccount Class - maybe you know, where I can find information about the difference and purposes?

    Thank you a lot!

    And the web role's onStart method listing:

    public override bool OnStart()
            {
    
                // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config  
                DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
                diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
                diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
                
                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
    
                return base.OnStart();
            }

    Saturday, November 24, 2012 4:38 PM
  • But I relly don't understand, why there are two different namespaces Microsoft.WindowsAzure.Storage and Windows.WindowsAzure both included CloudStorageAccount Class

    What has happened is that storage team has released version 2.0 of the storage client library. Version 2.0 is significantly different than version 1.7 and a lot of refactoring has been done. With version 1.7, everything was either in Microsoft.WindowsAzure or Microsoft.WindowsAzure.StorageClient namespaces while in 2.0 they were in different namespaces. For example, in 1.7 CloudStorageAccount was in Microsoft.WindowsAzure namespace while in 2.0 it is in Microsoft.WindowsAzure.Storage namespace.

    Coming back to diagnostics, try the following code. I created a simple worker role project:

            public override void Run()
            {
                DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
                config.OverallQuotaInMB = 4096;
                config.Logs.BufferQuotaInMB = 512;
                config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
                //config.DiagnosticInfrastructureLogs.BufferQuotaInMB = 512;
                //config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
    
                // Apply the updated configuration to the diagnostic monitor.
                // The first parameter is for the connection string configuration setting.
                DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
                
                // This is a sample worker implementation. Replace with your logic.
                Trace.WriteLine("WorkerRole1 entry point called", "Information");
    
                while (true)
                {
                    Thread.Sleep(10000);
                    Trace.WriteLine("Working", "Information");
                }
            }
    

    This is how the configuration file looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <ServiceConfiguration serviceName="WindowsAzure5" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2012-10.1.8">
      <Role name="WorkerRole1">
        <Instances count="1" />
        <ConfigurationSettings>
          <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
        </ConfigurationSettings>
      </Role>
    </ServiceConfiguration>

    Hope this helps. 

     

    Monday, November 26, 2012 6:21 AM