Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Table Storage - Create Connection String from a read-only SAS token

I was provided with an Azure table store SAS token with read-only access. I'm able to browse it using Azure Storage Explorer without issues. In trying to access it through a console app, I'm able to parse the connection string with the SAS token as a TableEndpoint but when I try and create the Table Client I get:

System.InvalidOperationException: No credentials provided. at Microsoft.WindowsAzure.Storage.CloudStorageAccount.CreateCloudTableClient()

This syntax I used for the connection string (with replaced values) is:

<add key="StorageConnectionString" value ="TableEndpoint=https://myaccount.table.core.windows.net/Table?sv=2015-04-05&amp;tn=Table&amp;sig=Signature&amp;se=2099-99-99T12%3A00%3A00Z&amp;sp=r" />

Finally, my console app code:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
like image 220
Joel Avatar asked Oct 16 '25 19:10

Joel


1 Answers

I think you need to use the StorageCredentials class. Here is a sample:

StorageCredentials accountSAS = new StorageCredentials(sasToken);
CloudStorageAccount accountWithSAS = new CloudStorageAccount(accountSAS, "account-name", endpointSuffix: null, useHttps: true);
CloudTableClient tableClientWithSAS = accountWithSAS.CreateCloudTableClient();
like image 187
Tigran Topchyan Avatar answered Oct 18 '25 07:10

Tigran Topchyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!