Reputation: 2189
I have generated a Shared Access Signature in the Azure portal. It gives me three strings: Connection string
, SAS token
, and Table service SAS URL
. I would have thought that I could take the value of Connection string
which contains the value of the SAS token
prefixed by a url and create a new TableClient
and query my table but it doesn't work.
Please note: I'm using Azure.Data.Tables 12.8.0
TableClient tc = new TableClient("<value-of-Connection-string>", "<my-table-name>");
var data = tc.Query<MyPoco>(); // I realize this is a table scan but don't care until it works
This returns error:
RequestFailedException: This request is not authorized to perform this operation using this resource type.
RequestId:dfe1fbe6-XXXX-002d-7997-XXXXXXXXXXXX
Time:2023-03-14T17:09:53.0004938Z
Status: 403 (Forbidden)
ErrorCode: AuthorizationResourceTypeMismatch
Can anyone help?
Upvotes: 0
Views: 1000
Reputation: 136356
If you want to use SAS URL to create an instance of TableClient
, please use the following constructor: TableClient(Uri, TableClientOptions)
where the URI is the SAS URL of the table in https://account.table.core.windows.net/table-name?sas-token
format.
Other alternative would be to use the following constructor: TableClient(Uri, AzureSasCredential, TableClientOptions)
where URI is the base URI of the table in https://account.table.core.windows.net/table-name
format and AzureSasCredential
is something you would create with your SAS token using something like:
var credentials = new AzureSasCredential(sasToken);
var tableClient = new TableClient(new Uri("https://account.table.core.windows.net/table-name"), credentials);
Upvotes: 1