.netazureazure-table-storagesemantic-loggingslab

How can I track the source of exception on trying to set Azure sink for a listener


I'm trying to use Semantic Logging Application Block to store logs into Azure Table Storage. Setup:

ObservableEventListener listener1 = new ObservableEventListener();
var conString =
    $"DefaultEndpointsProtocol={CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.Scheme};" +
    $"AccountName={CloudStorageAccount.DevelopmentStorageAccount.Credentials.AccountName};" +
    $"AccountKey={Convert.ToBase64String(CloudStorageAccount.DevelopmentStorageAccount.Credentials.ExportKey())}";
    
listener1.LogToWindowsAzureTable( // <---- EXCEPTION HERE
        instanceName: "instName",
        connectionString: conString);

I'm getting a strange exception:

Exception thrown: 'System.MissingMethodException' in Microsoft.Practices.EnterpriseLibrary.SemanticLogging.WindowsAzure.dll

Additional information: Method not found: 'Void Microsoft.WindowsAzure.Storage.Table.CloudTableClient.set_RetryPolicy(Microsoft.WindowsAzure.Storage.RetryPolicies.IRetryPolicy)'.

I have the same issue with a real account. Packages versions (all of them are from NuGet):

How can I track the source of the exception? Google says nothing about the method that is not found. A project to test on your machine is here.


Solution

  • The reason you're getting this error is because SLAB is dependent on storage client library 3.0.2.0 (source) and setting Retry Policies on client (CloudTableClient for example) was deprecated in version 4.0.0.0 (source) and removed in some later version (not sure which one).

    Because you're using version 7.x of storage client library, the method to set RetryPolicy on CloudTableClient is not there and hence you're getting this error.