【问题标题】:Azure Storage Emulator 403 ForbiddenAzure 存储模拟器 403 禁止
【发布时间】:2017-09-25 12:41:30
【问题描述】:

通过 Nuget,我将 WindowsAzure.Storage 升级为 8.1.1

然后我下载了AzureStorageEmulator 5.1.0.0 客户端。

我的连接字符串:

UseDevelopmentStorage=true;

自从以前它显然工作正常以来,我没有对代码进行任何更改。我知道得到例外:

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 677
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 604
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlobContainer.cs:line 233
   at C3.Code.Controls.Application.Storage.Blob.Blob.GetContainer(String containerName) in C:\Dropbox\Dropbox (Scirra Ltd)\Tom\C3 Website\C3Alpha2\Code\Controls\Application\Storage\Blob\Blob.cs:line 112
Request Information
RequestID:621bc19f-eb6a-4a98-b19e-f5b01ac22c26
RequestDate:Thu, 27 Apr 2017 16:17:34 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:621bc19f-eb6a-4a98-b19e-f5b01ac22c26
Time:2017-04-27T16:17:34.5166522Z

当我打电话时

var blobClient = GetClient();
var container = blobClient.GetContainerReference(containerName);
container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);

我看到系统时间会影响这一点,所以我检查了:

Server DateTime.UtcNow = 27/04/2017 16:17:34
Exception RequestDate = Thu, 27 Apr 2017 16:17:34 GMT

任何想法为什么我在更新客户端和 nuget 包后看到此错误?

编辑:GetClient() 代码:

private static CloudBlobClient GetClient()
{
    var account = CloudStorageAccount.Parse(Settings.Deployment.AzureConnectionString);
    return account.CreateCloudBlobClient();
}

编辑:BaseUri

基本 URI 是: http://127.0.0.1:10000/devstoreaccount1

访问这个我得到:

<Error>
<Code>InvalidQueryParameterValue</Code>
<Message>
Value for one of the query parameters specified in the request URI is invalid. RequestId:9cc906b0-eec6-44b2-bb3d-f77020af4a4c Time:2017-04-27T16:43:16.8538679Z
</Message>
<QueryParameterName>comp</QueryParameterName>
<QueryParameterValue/>
<Reason/>
</Error>

在存储模拟器初始化期间,它显示它已安装到:
(localdb)\MSSQLLocalDB as AzureStorageEmulatorDb51

来访:http://127.0.0.1:10000/azurestorageemulatordb51

演出:

<Error>
<Code>OutOfRangeInput</Code>
<Message>
One of the request inputs is out of range. RequestId:dab5e6c1-bc4a-4c65-a4d9-6d44634cb36a Time:2017-04-27T16:47:20.3093597Z
</Message>
</Error>

【问题讨论】:

  • 在您的异常堆栈跟踪中,为什么请求日期的时间是 15:01?这可能是此错误的原因吗?
  • @GauravMantri 更新了问题,抱歉从另一个错误消息中提取。所有日期似乎都相同(Datetime.UtcNow, Exception RequestDate)
  • 你确认模拟器已经启动了吗?
  • Azure 存储模拟器也使用本地数据库获取元数据,请确保您可以在 sql 中连接到它以查看该数据库

标签: azure http-status-code-403 azure-storage-emulator


【解决方案1】:

我也遇到了同样的问题,还尝试降级 WindowsAzure.Storage,但没有成功。经过一整天的尝试禁用所有功能后,我发现从 startup.cs 中删除这一行可以解决问题:

services.AddApplicationInsightsTelemetry(configuration);

我不知道为什么这些是相关的,以及为什么 ApplicationInsights 会导致 Azure 存储出现问题。我尝试使用 Microsoft.ApplicationInsights.AspNetCore 的 2.1.0-beta2 和 2.0.0 版本,都导致 403 错误。

【讨论】:

  • 我们今天升级到 AppInsights 2.4 时才得到这个
  • 我刚用本地模拟器遇到了这个问题。这是否只发生在本地模拟器或 Azure 中?
  • 我将 Microsoft.ApplicationInsights.AspNetCore 从 2.1.0 降级到 2.0.1 来解决这个问题。
  • 我在升级到 Microsoft.ApplicationInsights 2.4.0 后开始遇到此问题。通过降级到 2.3.0 解决。
  • 此问题已在 ASP.NET Core v2.1.1 中修复:github.com/Microsoft/ApplicationInsights-aspnetcore/releases/…
【解决方案2】:

您可以通过修改 ApplicationInsights.config 文件并将 localhost 添加到 ExcludeComponentCorrelationHttpHeadersOnDomains 部分来解决 Application Insights 版本 2.4.0 的此问题:

<ExcludeComponentCorrelationHttpHeadersOnDomains>
    <Add>localhost</Add>
    <Add>127.0.0.1</Add>
    <Add>core.windows.net</Add>
    <Add>core.chinacloudapi.cn</Add>
    <Add>core.cloudapi.de</Add>
    <Add>core.usgovcloudapi.net</Add>
</ExcludeComponentCorrelationHttpHeadersOnDomains>

【讨论】:

  • 更新到 2.4.1 对我不起作用。但是,此配置更改确实发生了。只需要记住在下一次 NuGet 更新后取消它
  • 取消! :D 喜欢它!
【解决方案3】:

将 Application Insights 从版本 2.4 升级到 2.4.1 解决了这个问题。

注意:当我选择将 AI 添加到我的项目(使用向导)时,添加了 2.4 版。令人惊讶的是,添加的版本并不是最新的 AI 版本。我不得不去 NuGet 并手动升级到最新版本。

【讨论】:

  • 这里也是 ApplicationInsights 在将 Azure Storage Emulator 升级到 5.10 后导致的问题。通过将 ApplicationInsights 从 2.4.0 更新到 2.10.0(今天的最新版本)解决了这个问题。
【解决方案4】:

我遇到了同样的问题,找不到任何解决方案来解决这个问题。它似乎真的连接到 ApplicationInsights - 从干净的控制台应用程序直接调用本地模拟器工作正常,从具有 ApplicationInsights 的 Web 项目调用模拟器返回 403。

您可以使用另一个 storage emulator 或使用真正的 Azure Blob 存储。

【讨论】:

    【解决方案5】:

    将 Application Insights 包安装到我们的业务规则项目后,我们遇到了同样的问题。 我们有一个带有 asp.net 核心的 N 层解决方案,它具有不同版本的应用程序洞察力。

    原来我们在业务规则中安装了非asp.net核心包,然后在访问队列客户端时产生了Forbidden 403错误。

    我们删除了非 asp.net 核心应用程序洞察,将应用程序洞察核心安装到业务规则项目中,一切正常。

    【讨论】:

    • 升级到 Application Insights 2.4 并出现此错误,降级到 2.3 为我修复了它
    • 其实我们也同时把业务规则包降级到了2.3版本(和.net core项目是同一个版本)。它以前是 Application Insights 2.4。我忘记了那一步!
    【解决方案6】:

    对于那些没有看到的人

    services.AddApplicationInsightsTelemetry(configuration);

    在他们的Startup.cs 文件中,ApplicationInsight 配置可能在Program.cs 中完成,如下所示:

    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<Startup>()
        .UseApplicationInsights() /* HERE */
        .Build();
    

    【讨论】:

      猜你喜欢
      • 2018-05-17
      • 2013-08-18
      • 2020-04-05
      • 2013-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多