none
Urgent !!! Query Azure Table with Shared Access Signature returns not implemented, but with connection string works

    Question

  • Spend many hours to try to sort this out. Need to solve it quickly. Any idea is appreciated.

    I have a table and want to create a read-only SAS and give to client components to read access. But never succeed.

    If just use connection string and hook up table directly like this:

        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(SliStorageConnection);
    
        // Create the table client.
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
    
        var table = tableClient.GetTableReference(GlobalFilterTable);
    
        TableOperation tableOperation = TableOperation.Retrieve<TableEntity>(FilterTablePartition, "filter1");
        TableResult tableResult = table.Execute(tableOperation);

    It works fine. But with SAS like below, always returns 501 Not Implemented

        var policy = new SharedAccessTablePolicy
        {
            SharedAccessExpiryTime = DateTime.Now.AddMinutes(30),
            Permissions = SharedAccessTablePermissions.Query
        };
    
        string sas = table.GetSharedAccessSignature(
            policy,
            null,
            FilterTablePartition,
            String.Empty,
            FilterTablePartition,
            String.Empty);
    
        Uri tableSasUri = new Uri(table.Uri, sas);
        AccessTable(tableSasUri.AbsoluteUri.ToString());
    
    private static void AccessTable(string tableSas)
    {
        string filterTableBaseUrl = tableSas.Substring(0, tableSas.IndexOf('?'));
    
        var filterTableSasCredentials = new StorageCredentials(tableSas.Substring(filterTableBaseUrl.Length));
        CloudTableClient tableClient = new CloudTableClient(new Uri(filterTableBaseUrl), filterTableSasCredentials);
    
        var _manifestFilterCloudTable = tableClient.GetTableReference(GlobalFilterTable);
    
        TableOperation tableOperation = TableOperation.Retrieve<TableEntity>(FilterTablePartition, "filter1");
        TableResult tableResult = _manifestFilterCloudTable.Execute(tableOperation);
    }

    Tried different ways, give less than 1 hour time, named or anonymous policy identifier, use signature only ("sig") to create StorageCredentials. All failed with different errors. Mostly 501 not implemented, sometime resource not found, sometimes 403 Forbidden.

    Couldn't find useful info online. I am using Microsoft.WindowsAzure.Storage version 3.1 SDK.

    Any help is highly appreciated


    • Edited by slicoder Saturday, January 31, 2015 11:31 PM
    Saturday, January 31, 2015 6:05 PM

Answers

All replies