2017-05-05 1 views

答えて

0

正常に実行されたか、何らかの障害が発生したかどうかを、azureポータルからメールで通知する方法。

私はAzureポータルでこれを行う方法が見つかりませんでした。コードを修正して実装することができます。

私のoriginal postsの1つとして、WebJobのステータスは、WebJob /機能が例外なく実行されているかどうかによって異なります。すべてのコードをtryコードブロックに入れることをお勧めします。例外がスローされた場合、この実行のステータスは失敗となります。それ以外の場合、ステータスは成功します。

try 
{ 
    //Put all your code here 
    //If no exception throws, the status of this run will be success 
    //Send success status to your mail 
} 
catch 
{ 
    //If any exception throws, the status of this run will be failure 
    //Send failure status to your mail 
} 

WebJobでメールを送信するには、SendGridコンポーネントまたはその他のSMTPクライアントライブラリを使用できます。ここでは、SmtpClientを使用してHotmailからメールを送信するサンプルを示します。

MailMessage mail = new MailMessage("[email protected]", "[email protected]"); 
SmtpClient client = new SmtpClient(); 
client.Port = 587; 
client.EnableSsl = true; 
client.Credentials = new NetworkCredential("[email protected]", "mail_password"); 
client.DeliveryMethod = SmtpDeliveryMethod.Network; 
client.Host = "smtp.live.com"; 
mail.Subject = "this is a test email."; 
mail.Body = "this is my test email body"; 
client.Send(mail); 
関連する問題