none
Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden

    Question

  • Hi,

    I am trying to access table storage using sas token. While accessing i am getting following error:

    {Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
       at Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpResponseParsers.TableOperationPreProcess(TableResult result, TableOperation operation, HttpWebResponse resp, Exception ex) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\Protocol\TableOperationHttpResponseParsers.cs:line 53
       at Microsoft.WindowsAzure.Storage.Table.TableOperation.<>c__DisplayClass4.<InsertImpl>b__2(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\TableOperation.cs:line 144
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 299
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 50
       at Microsoft.WindowsAzure.Storage.Table.CloudTable.EndExecute(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:line 96
       at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 66
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at Itron.Cloud.Platform.EventProcessor.Repository.Storage.TableStorageRepository.<>c__DisplayClass7_0.<<SendDataAsync>b__0>d.MoveNext() in C:\Project\Itron.Cloud.Platform.EventProcessor\Itron.Cloud.Platform.EventProcessor\Repository\Storage\TableStorageRepository.cs:line 55
    Request Information
    RequestID:d24e0131-0002-0028-1d68-87ec52000000
    RequestDate:Wed, 15 Feb 2017 08:49:47 GMT
    StatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
    ErrorCode:AuthenticationFailed
    ErrorMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
    RequestId:d24e0131-0002-0028-1d68-87ec52000000
    Time:2017-02-15T08:49:47.8115785Z

    Code which i have used to connect to storage account using sas.

                    StorageCredentials accountSAS = new StorageCredentials(storageSasToken);
                    CloudStorageAccount account = new CloudStorageAccount(accountSAS, "Account_name", endpointSuffix: null, useHttps: true);
                    CloudTableClient tableClient = account.CreateCloudTableClient();
    CloudTable table = client.GetTableReference("Tablename");
    table.CreateIfNotExists();
    
    
    

    It throws exception at line 

    table.CreateIfNotExists();

    Is it something related to CORS?

    Wednesday, February 15, 2017 3:11 PM

All replies

  • There are two types of Storage Accounts. General-purpose storage account and Blob storage account. Which one of the two are you trying to create? You need to ensure you're using General-Purpose storage account for using Table Storage. You may also refer this sample code for CORS with Azure Storage (for blob and table services). 


    • Proposed as answer by Md Shihab Sunday, February 19, 2017 7:34 AM
    Thursday, February 16, 2017 8:46 AM