5

デプロイメントがリサイクルでループする問題が発生しています。 Visual Studioから:AzureワーカーロールのonStartメソッドで例外をキャッチしていますか?

"ロールインスタンスは、更新またはアップグレード操作中に一定期間リサイクルされました。これは、サービスの新しいバージョンまたはサービスの構成時に指定した構成設定がロールインスタンスの実行を妨げていることを示します。これは、コードが処理されない例外をスローする可能性があるためです。サービスを修正したり、ロールインスタンスが未処理の例外をスローしないように構成設定を変更したりしてから、別の更新またはアップグレード操作を開始してください。 Windows Azureはサービスを新しいバージョンまたは提供した設定に更新しようとします。

質問:例外をキャッチする最も良い方法は何ですか?私はC#でちょっと新しいです。ケースの私のONSTARTの要約版は役立ちます:

また
public override void Run() 
    { 
     // This is a sample worker implementation. Replace with your logic. 
     Trace.WriteLine("WorkerRole1 entry point called", "Information"); 

     while (true) 
     { 
      Thread.Sleep(10000); 
      Trace.WriteLine("Working", "Information"); 
     } 
    } 

public override bool OnStart() 
    { 

     // Set the maximum number of concurrent connections 
     ServicePointManager.DefaultConnectionLimit = 12; 

     // Retrieve storage account from Connection String 
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); 

     // Create blob client 
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

     // retrieve reference to container (blob resides within container) 
     CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); 

     // create container if it doesn't already exist 
     container.CreateIfNotExist(); 

     // make container public *temp* 
     container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); 

     // Retrieve references to required blobs 
     CloudBlob batch = container.GetBlobReference("batch.bat"); 

     // Download batch file 
     using (var fileStream = System.IO.File.OpenWrite(@"C:\batch.bat")) 
     { 
      zip.DownloadToStream(fileStream); 
     } 


     // run batch file 

     System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
     proc.StartInfo.FileName = "C:\\batch.bat"; 
     proc.StartInfo.RedirectStandardError = false; 
     proc.StartInfo.RedirectStandardOutput = false; 
     proc.StartInfo.UseShellExecute = false; 
     proc.Start(); 
     proc.WaitForExit(); 

     return base.OnStart(); 
    } 
} 

}

場合には、それはRDPからスタックトレースがあり、ここで、役立ちます:

Stack: 


at System.IO.__Error.WinIOError(Int32, System.String) 
at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean) 
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean) 
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare) 
at System.IO.File.OpenWrite(System.String) 
at WorkerRole1.WorkerRole.OnStart() 
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleType) 
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0() 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
at System.Threading.ThreadHelper.ThreadStart() 
+1

あなたの質問に正確な答えはありませんが、コードがアクセスしようとしています。c:そのようなアクセスをローカルストレージに置き換える必要があります。[link](http://msdn.microsoft.com/en-us/library/ windowsazure/ee758708.aspx)。例:[リンク](http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.serviceruntime.localresource.aspx) – RichBower

+0

ありがとうリッチ!それは問題を解決しました:) – RobVious

答えて

8

私のブログの記事Printf("HERE") in the Cloudを助けるかもしれません。本質的には、try/catchで全体をラップし、エラーをログに記録します。

+0

非常にクールです。ありがとうございます :) – RobVious

関連する問題