0
votes

I am getting the error below when trying to create a new table in a new Azure storage account from Azure Websites. It works when I try to do it from my local machine. It also works when I use my old Azure storage account.

System.AggregateException was unhandled by user code
HResult=-2146233088 Message=One or more errors occurred.
Source=mscorlib StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at MyProject.Data.Repositories.MatchRepository..ctor(CloudStorageAccount storageAccount) in D:\home\site\approot\src\MyProject.Data\Repositories\MatchRepository.cs:line 15 at MyProject.Startup.ConfigureStorageRepositoriesAndServices(IServiceCollection services, CloudStorageAccount storageAccount) in D:\home\site\approot\src\MyProject\Startup.cs:line 98 at MyProject.Startup.ConfigureServices(IServiceCollection services) in D:\home\site\approot\src\MyProject\Startup.cs:line 86
InnerException: ErrorCode=-2147217005 HResult=-2147217005 Message= 403
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
Primary
0d907af5-0002-0117-126c-ea972b000000 Tue, 08 Sep 2015 19:31:47 GMT Tue, 08 Sep 2015 19:31:43 GMT Tue, 08 Sep 2015 19:31:47 GMT
AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:0d907af5-0002-0117-126c-ea972b000000 Time:2015-09-08T19:31:46.4165753Z
StorageException -2146233088 Unexpected response code, Expected:OK or NotFound, Received:Forbidden Microsoft.WindowsAzure.Storage at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__41.MoveNext()</StackTrace> </ExceptionInfo> </RequestResult> Source=Microsoft.WindowsAzure.Storage StackTrace: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__41.MoveNext() --- 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 Microsoft.WindowsAzure.Storage.Table.CloudTable.<>c__DisplayClass51_0.<b__0>d.MoveNext() --- 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 Microsoft.WindowsAzure.Storage.Table.CloudTable.<>c__DisplayClass41_0.<b__0>d.MoveNext() --- 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.TaskAwaiter1.GetResult() at MyProject.Data.TableRepository.<CreateTableAsync>d__13.MoveNext() in D:\home\site\approot\src\MyProject.Data\Common\TableRepository.cs:line 29 --- 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.TaskAwaiter1.GetResult() at MyProject.Data.Repositories.MatchRepository.d__2.MoveNext() in D:\home\site\approot\src\MyProject.Data\Repositories\MatchRepository.cs:line 20 InnerException: HResult=-2146233088 Message=Unexpected response code, Expected:OK or NotFound, Received:Forbidden Source=Microsoft.WindowsAzure.Storage StackTrace: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.d__4`1.MoveNext() InnerException:

1
can you share the code that fails? also does it work locally?Amit Apple

1 Answers

1
votes

It seems that you are using your manage keys in a wrong way.

web.config:

<configuration>
    <appSettings>
        <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey=nYV0gln9fT7bvY+rxu2iWAEyzPNITGkhM88J8HUoyofpK7C8fHcZc2kIZp6cKgYRUM74lHI84L50Iau1+9hPjB==" />
    </appSettings>
</configuration>

c# code:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    ConfigurationManager.AppSettings["StorageConnectionString"]);

source:

https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-tables/