如何使用 .Net Standard 查询 Azure Table 存储

How to Query Azure Table storage using .Net Standard

我在 UWP 上有一个 .Net Standard 客户端应用程序 运行。

我的客户端应用程序联系生成 sas 密钥的服务器,如下所示:

var myPrivateStorageAccount = CloudStorageAccount.Parse(mystorageAccountKey);
var myPrivateTableClient = myPrivateStorageAccount.CreateCloudTableClient();
SharedAccessTablePolicy pol = new SharedAccessTablePolicy()
{
    SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(59),
    Permissions = SharedAccessTablePermissions.Query | SharedAccessTablePermissions.Add
};
CloudTable myPrivateTable = myPrivateTableClient.GetTableReference(tableName);
String sas = myPrivateTable.GetSharedAccessSignature(pol);
return sas;

然后我的客户端应用程序运行以下内容:

StorageCredentials creds = new StorageCredentials(sas);

this.tableClient = new CloudTableClient(tableServiceURI, creds);
this.table = tableClient.GetTableReference(tableName);
TableQuery<DynamicTableEntity> projectionQuery = new TableQuery<DynamicTableEntity>().Select(new string[] { "DocumentName" }).Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, cc));
 var res = await table.ExecuteQuerySegmentedAsync<DynamicTableEntity>(projectionQuery, null);

并出现以下错误:

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. sr is mandatory. Cannot be empty

但因为这是表存储 I dont think sr is required

我的 SAS 密钥对我来说没问题:

?sv=2018-03-28&tn=MyTable&sig=RandomSig151235341543&st=2019-01-17T12%3A00%3A28Z&se=2019-01-17T12%3A59%3A28Z&sp=ra

所以这里有什么问题?

好吧,这有点愚蠢,但我还是会 post。

我正在将请求发送至:

https://myaccount.blob.core.windows.net/

并且应该将请求发送至:

https://myaccount.table.core.windows.net/