【问题标题】:How to Query Azure Table storage using .Net Standard如何使用 .Net Standard 查询 Azure 表存储
【发布时间】:2019-01-17 12:50:25
【问题描述】:

我有一个在 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);

并得到以下错误:

服务器未能验证请求。确保值 授权标头正确形成,包括签名。 sr 是强制性的。不能为空

但是因为这是表存储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

那么这里的问题是什么?

【问题讨论】:

  • 你能分享你的 SAS 令牌吗?
  • @GauravMantri 共享
  • 您的 SAS 令牌在我看来没问题。您能否确认 SAS 令牌的表与执行查询的表相同?另外,请通过 Fiddler 之类的工具跟踪请求/响应。您将在响应正文中获得更详细的错误消息。

标签: c# azure uwp azure-table-storage .net-standard


【解决方案1】:

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

我将请求发送到:

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

并且应该已经将请求发送到:

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

【讨论】:

    猜你喜欢
    • 2011-08-01
    • 2020-11-20
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-17
    相关资源
    最近更新 更多