2017-05-05 59 views

回答

0

如何從Azure門戶郵件中獲取Azure Web作業運行警報,以確定其運行是否成功或發生任何故障。

我還沒有發現任何方式做它在Azure門戶。你可以修改你的代碼來實現它。

由於我original posts提到,WebJobs狀態一個取決於是否沒有任何異常或不執行你的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); 
相關問題