2012-01-10 4 views
3

私のローカルPCからクライアントサイドのAzure SDKを使用して実際にODDの問題が発生しています。Azure Blobストレージのダウンロード:サーバの認証に失敗しましたが、再試行でOK

CloudBlobClientを使用してファイルをアップロードおよび削除すると、charmのように動作しますが、ファイルをダウンロードしようとすると、認証例外(基本的に403禁止)が表示されます。 しかし、もし私がと同じコードを再試行すると、次回はの周りで動作します。
誰にも何らかのアイデアがありますか?ここで

は、問題を示し、いくつかの単純化されたコードです:

string blobEndpoint = "http://???.blob.core.windows.net"; 
    string accountName = "???"; 
    string accountKey = "???"; 

     while(retry) 
     { 
      FileStream stream = new FileStream("C:\\temp\\mydownload.jpg", FileMode.Append); 

      try 
      { 
       CloudBlobClient blobClient = 
       new CloudBlobClient(new Uri(blobEndpoint), new StorageCredentialsAccountAndKey(accountName, accountKey)); 

       CloudBlob blob = blobClient.GetBlobReference("documents/drive.png"); 

       blob.DownloadToStream(stream); 

       retry = false; 
      } 
      catch (Exception ee) 
      { 
       if (MessageBox.Show(ee.Message.ToString(), "ARGH!", MessageBoxButtons.RetryCancel) != System.Windows.Forms.DialogResult.Retry) 
        retry = false; 
      } 
      finally 
      { 
       stream.Flush(); 
       stream.Close(); 
      } 

     } 

生成される例外は次のとおりです。

Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled 
    Message=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. 
    Source=Microsoft.WindowsAzure.StorageClient 
    StackTrace: 
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result() 
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.Execute() 
     at Microsoft.WindowsAzure.StorageClient.RequestWithRetry.RequestWithRetrySyncImpl[TResult](ShouldRetry retryOracle, SynchronousTask`1 syncTask) 
     at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteSyncTaskWithRetry[TResult](SynchronousTask`1 syncTask, RetryPolicy policy) 
     at Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadToStream(Stream target, BlobRequestOptions options) 
     at Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadToStream(Stream target) 
     at TestAzure.Form1.button1_Click(Object sender, EventArgs e) in c:\users\richard.donaldson\documents\visual studio 2010\Projects\TestAzure\TestAzure\Form1.cs:line 41 
     at System.Windows.Forms.Control.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
     at System.Windows.Forms.Button.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.Run(Form mainForm) 
     at TestAzure.Program.Main() in c:\users\richard.donaldson\documents\visual studio 2010\Projects\TestAzure\TestAzure\Program.cs:line 18 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: System.Net.WebException 
     Message=The remote server returned an error: (403) Forbidden. 
     Source=System 
     StackTrace: 
      at System.Net.HttpWebRequest.GetResponse() 
      at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponseSync(WebRequest req, EventHandler`1 handler, Object sender) 
     InnerException: {"The remote server returned an error: (403) Forbidden."} 
+0

+1コードサンプルの整形式質問については、また、 "ARGH!"メッセージボックスタイトルとして。 – ean5533

答えて

0

にもPHPのためのWindows AzureのSDKを使用しているとき、私はこの問題全体を実行しています。当時あなたのアプリで何か変わった動作が見受けられましたか? I.遅い応答、主要なネットワークの待ち時間など

追加: ループのように複数の接続を素早く作成していましたか?

+0

いいえ - 単なる接続です。 – user1141368

+0

ハハハハ。ガー。私はHTTPSに変更しましたが、今は正常に動作します。とにかくSSLを使用する必要がありますので、本当に心配する必要はありませんが、httpエンドポイントで動作する必要はありません – user1141368

2

ハハハハ。ガー。私はちょうどそれをHTTPSに変更しました、そして今それは正常に動作します。おそらくSSLを使用する必要があります。本当に心配する必要はありませんが、エンドポイントでは動作しません。

関連する問題