0
votes

Read access through Azure Storage Explorer or regular browser works for the on-hand SAS token. Console access is throwing a Forbidden (403) exception.

Code as below for the referenced appconfig:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <appSettings>
      <add key="SASToken" value="sv=[REMOVED]&amp;tn=[REMOVED]&amp;sig=[REMOVED]&amp;se=[REMOVED]&amp;sp=r" />
    </appSettings>
</configuration>

Code as below for the console app:

StorageCredentials accountSAS = new StorageCredentials(CloudConfigurationManager.GetSetting("SASToken"));
CloudStorageAccount accountWithSAS = new CloudStorageAccount(storageCredentials: accountSAS, accountName: "acccount-name",  endpointSuffix: "core.windows.net", useHttps: true);
CloudTableClient tableClient = accountWithSAS.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("TableName");

if (table.Exists() == true)
{
    Console.WriteLine("Table Exists.");
}
else
    Console.WriteLine("Table Does not Exist.");
1
I'm confused - are you taking a pre-generated SAS token and appending it to your various connections? If so: That's not how SAS works. - David Makogon
I'm just trying to establish one connection to a table storage through a console app using a read-only SAS token I was provided with. - Joel

1 Answers

1
votes

From my experience, 403 error indicates that it has no permission to do that. It means that with Service (table) SAS that has no permission to check whether the table is existing. If we want to check if the table is existing, we need storage Account level SAS but not the Service (table) SAS. More info please refer to types of shared access signatures. Although we don’t have the permission to check whether table is existing, we still have the access that SAS assigned. we also can use table query to retrieve the table records. e.g. var result = table.ExecuteQuery(new TableQuery {TakeCount =5}); It will get the similar result with the regular browser does.