azure-sdk-for-net: Azure.Data.Tables 12.0.0-beta.8 - NullReferenceException in tableClient.DeleteEntity

Describe the bug NullReferenceException in tableClient.DeleteEntity call

Expected behavior Row added and deleted.

Actual behavior (include Exception or Stack Trace) Row is added but not deleted because of exception.

To Reproduce

            var tableClient = new TableClient(<cs>, <table>);
            var entity = new TableEntity("a", "b")
            {
                { "Product", "Marker Set" }
            };
            tableClient.AddEntity(entity);
            tableClient.DeleteEntity("a", "b");

Environment:

  • Azure.Data.Tables 12.0.0-beta.8
  • Win 10 .NET 3.1
  • Visual Studio 16.9.6

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

@christothes This solves the issue for me.

To awnser your question, for me it wasn’t in an Azure Function context. I was using it to write my workflow data to tablestorage.

Btx, thnx for the quick fix!

I have a fix, but here is a workaround in the meantime. The issue only exists when the TableClient is created with the connectionString constructor. Here is how you can take a connection string and turn it into a TableSharedKeyCredential so that the other ctor can be used until a fix is available:

var pairs = storageTableConnectionString
    .Split(';')
    .Select<string, KeyValuePair<string,string>>(p =>
    {
        var pair = p.Split('=', 2);
        return KeyValuePair.Create(pair[0], pair[1]);
    })
    .ToDictionary(p => p.Key, p => p.Value);

string accountName = pairs["AccountName"];
var cred = new TableSharedKeyCredential(accountName, pairs["AccountKey"]);
var uri = new Uri($"https://{accountName}.table.core.windows.net");

TableClient client = new TableClient(uri, "deleteThisTable", cred);