0
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 1 year has passed since last update.

なぜかAzure Storage accountsの接続エラーが発生した

Posted at

経緯

C#で作ったWebAPI経由で、Azure Storage accountsにファイルをアップロードしたりダウンロードしたり、削除したりするアプリを保守運用しています。
そのアプリに、ユーザからエラー報告が来ていたため、調査・修正を行いました。

※先に述べておきますが、明確なエラー原因は分かりませんでした。修正コード書いているうちに勝手に直っていました。

エラー内容

手書きで写したので、間違いなどあるかもしれませんが、、

エラーメッセージ
Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server
 ---> System.Net.WebException: Unable to connect to the remote server
 ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond // IDアドレスとポート番号? // at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapShot, SocketAddress socketAddress) At System.Net.ServicePoint.ConnectSoketInternal(Boolean connectFailure, Socket s4, Socket s6, Soket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
 --- End of inner exception stack trace
 --- at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in // ディレクトリ //
 --- End of inner exception stack trace
 (後略)

もうちょっと詳しく見ると、404エラーが返ってきたと書いてありました。

調査

調査、修正は以下の流れで行いました。

  1. エラー報告を受け、調査を開始
  2. 検証環境ではエラーが再現しないことを確認
  3. 本番環境でのエラーが再現することを確認
  4. ローカル環境でもエラーは再現しないが、本番環境のAzure Storage accountsの接続文字列を使うと再現した
    →コードは特に問題が無く、本番環境のAzure Storage accountsが問題っぽい?
  5. 本番環境と検証環境のAzure Storage accountsを比較するが、特に差異は見当たらず
  6. 以前、本番環境のAzure ADを利用したログインだけが出来なくなった経験があるため、Nugetパッケージを疑ってみることに
    Azure Storage accountsにアクセスするのに利用していたNugetパッケージは「WindowsAzure.Storage」だが、非推奨になっていた。
    そこで、今回はこのパッケージを原因と仮定し、「Azure.Storage.Blobs」を使ったものに書き換えることにした。
  7. コードを修正し、ローカルで本番環境のAzure Storage accountsに接続すると、ファイルを取得できたため、そのまま作業を進める
  8. 修正が完了し、検証環境でのテストも完了したが、適用前に本番環境のエラーが再現するか確かめてみたところ、なぜかファイルが取得できた、、

ということで、なぜか勝手に直っていたので、金曜日ということもあり、本番環境適用は見送りました。

原因

原因は以下の2つだろう、という推測で終わりました。

  1. 本番環境のAzure Storage accountsが不安定だった
  2. 非推奨のNugetパッケージ「WindowsAzure.Storage」を使っていた

最後に

Nugetパッケージに限らず、利用しているものが非推奨になっていないか、なども気をつけないといけませんね、、

0
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
0
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?