3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Azure Storage と Application Insightsで403エラーが発生

Posted at

概要

実稼働中のWebアプリケーション(Storage追加済み)に、Application Insights を追加したら403エラーが止まらなくなったお話です。

環境

  • .Net Framework 4.6.1
  • WindowsAzure.Storage 8.6.0
  • Microsoft.ApplicationInsights 2.4.0

ちなみにStorageへのアクセスはPrimary keyを使ってます。

起こったこと

概要に書いている通りですが、Insights を追加したあたりから、

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

というところまで実行したところで

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.

が出るようになってしまった。

どうやって直したか

azure-sdk-for-netのIssues
403 Forbidden when connecting to Azure Storage with Application Insights Web Tracking HTTP Module
を参考に、ApplicationInsights.configに以下を追加することで、無事解消しました。

<TelemetryModules>
  <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
    <ExcludeComponentCorrelationHttpHeadersOnDomains>
      <Add>core.windows.net</Add>
      <Add>core.chinacloudapi.cn</Add>
      <Add>core.cloudapi.de</Add>
      <Add>core.usgovcloudapi.net</Add>
      <Add>localhost</Add>
      <Add>127.0.0.1</Add>
    </ExcludeComponentCorrelationHttpHeadersOnDomains>
  </Add>
</TelemetryModules>
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?