gpt4 book ai didi

azure - 如何从 azure 门户获取邮件中的 azure web 作业运行警报?

转载 作者:行者123 更新时间:2023-12-03 04:25:37 25 4
gpt4 key购买 nike

我已将控制台应用程序安排为 Azure 门户中的 Web 作业。

如何从 azure 门户的邮件中获取 azure web 作业运行警报,了解它是否运行成功或发生任何失败。

最佳答案

how to get azure web job running alert in mail from azure portal that whether it runs successfully or any failure occurred.

我还没有在 Azure 门户上找到任何方法来执行此操作。您可以修改代码来实现它。

正如我的 original posts 中提到的,WebJobs 状态取决于您的 WebJob/Function 是否在没有任何异常的情况下执行。我建议您将所有代码放在 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("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95f3e7faf8f8f4fcf9d5fdfae1f8f4fcf9bbf6faf8" rel="noreferrer noopener nofollow">[email protected]</a>", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="780c17151911143810170c15191114561b1715" rel="noreferrer noopener nofollow">[email protected]</a>");
SmtpClient client = new SmtpClient();
client.Port = 587;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0264706d6f6f636b6e426a6d766f636b6e2c616d6f" rel="noreferrer noopener nofollow">[email protected]</a>", "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);

关于azure - 如何从 azure 门户获取邮件中的 azure web 作业运行警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43802834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com