尝试从Azure网站创建Azure存储表时出现错误403

时间:2015-09-08 19:41:30

标签: azure azure-web-sites azure-table-storage

尝试在Azure网站的新Azure存储帐户中创建新表时,我收到以下错误消息。当我尝试从我的本地机器上执行此操作时,它可以正常工作当我使用旧的Azure存储帐户时,它也可以工作。

  

System.AggregateException未被用户代码
处理   HResult = -2146233088消息=发生了一个或多个错误   Source = mscorlib StackTrace:          在System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)          在System.Threading.Tasks.Task 1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task 1.get_Result()          在MyProject.Data.Repositories.MatchRepository..ctor(CloudStorageAccount   storageAccount)in   d:\家\网站\为approot的\ src \ MyProject.Data \库\ MatchRepository.cs:行   15          在MyProject.Startup.ConfigureStorageRepositoriesAndServices(IServiceCollection   服务,CloudStorageAccount storageAccount)中   D:\ home \ site \ approot \ src \ MyProject \ Startup.cs:第98行          在D:\ home \ site \ approot \ src \ MyProject \ Startup.cs中的MyProject.Startup.ConfigureServices(IServiceCollection服务):第86行   的InnerException:          错误码= -2147217005          的HResult = -2147217005          消息=      403个
  服务器无法验证请求。使   确保正确形成Authorization标头的值,包括   签名。
  主要
  0d907af5-0002-0117-126c-ea972b000000         星期二,2015年9月8日19:31:47   格林威治标准时间星期二,2015年9月8日19:31:43   GMT Tue,2015年9月8日19:31:47 GMT
         AuthenticationFailed       服务器无法验证请求。确保正确形成Authorization标头的值,包括   签名。请求ID:0d907af5-0002-0117-126c-ea972b000000   时间:2015-09-08T19:31:46.4165753Z
         StorageException       -2146233088       意外的响应代码,预期:OK或NotFound,收到:禁止       Microsoft.WindowsAzure.Storage          在Microsoft.WindowsAzure.Storage.Core.Executor.Executor。&lt; ExecuteAsyncInternal&gt; d__4 1.MoveNext()</StackTrace> </ExceptionInfo> </RequestResult> Source=Microsoft.WindowsAzure.Storage StackTrace: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4 1.MoveNext()            ---从抛出异常的先前位置开始的堆栈跟踪结束---               在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)               在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)               在Microsoft.WindowsAzure.Storage.Table.CloudTable。&lt;&gt; c__DisplayClass51_0。&lt; b__0&gt; d.MoveNext()            ---从抛出异常的先前位置开始的堆栈跟踪结束---               在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)               在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)               在Microsoft.WindowsAzure.Storage.Table.CloudTable。&lt;&gt; c__DisplayClass41_0。&lt; b__0&gt; d.MoveNext()            ---从抛出异常的先前位置开始的堆栈跟踪结束---               在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)               在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)               在System.Runtime.CompilerServices.TaskAwaiter 1.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.TaskAwaiter 1.GetResult()               在MyProject.Data.Repositories.MatchRepository.d__2.MoveNext()   在   d:\家\网站\为approot的\ src \ MyProject.Data \库\ MatchRepository.cs:行   20          的InnerException:               的HResult = -2146233088               Message =意外的响应代码,预期:OK或NotFound,Received:Forbidden               来源= Microsoft.WindowsAzure.Storage               堆栈跟踪:                    在Microsoft.WindowsAzure.Storage.Core.Executor.Executor.d__4`1.MoveNext()               的InnerException:

1 个答案:

答案 0 :(得分:1)

您似乎以错误的方式使用管理密钥。

的web.config:

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

c#c​​ode:

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

源:

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