Reputation: 869
I create a SAS on a given table, using the .NET API:
var tablePolicy = new SharedAccessTablePolicy()
{
SharedAccessExpiryTime = DateTime.Now.Add(TimeSpan.FromHours(2)),
Permissions = SharedAccessTablePermissions.Query
};
var permissions = new TablePermissions();
permissions.SharedAccessPolicies.Add("myPolicy", tablePolicy);
var credentials = new StorageCredentials(
"#my account here#",
"#my account secondary key here#");
var tableClient = new CloudTableClient(
new Uri("https://#my account here#.table.core.windows.net/"),
credentials);
var logTable = tableClient.GetTableReference("WADLogsTable");
logTable.SetPermissions(permissions);
var sas = logTable.GetSharedAccessSignature(tablePolicy, "myPolicy", null, null, null, null);
I then take this last 'sas' variable and use it to create credentials and perform a query:
var credentials = new StorageCredentials(sas);
var tableClient = new CloudTableClient(
new Uri("#my account URI here#"),
credentials);
var logTable = tableClient.GetTableReference("WADLogsTable");
var rows = logTable.ExecuteQuery(new TableQuery()).ToArray();
I then receive a 403 (forbidden) error.
What did I do wrong?
Upvotes: 2
Views: 2450
Reputation: 136306
I believe you're getting this error because you're defining both SharedAccessTablePolicy
and Policy Name
when creating SAS. So if you use either of the following that should work:
var sas = logTable.GetSharedAccessSignature(tablePolicy, null, null, null, null, null);
or
var sas = logTable.GetSharedAccessSignature(null, "myPolicy", null, null, null, null);
Upvotes: 2