【发布时间】:2013-12-25 03:05:01
【问题描述】:
以下 Global.asax 中的代码在 IIS 上运行良好,但是当我将应用程序部署到 Azure 时它不起作用。
protected void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 60000;
timer.AutoReset = true;
timer.Elapsed += new ElapsedEventHandler(NewCandidates);
timer.Enabled = true;
}
public void NewCandidates(object source, System.Timers.ElapsedEventArgs e)
{
SendEmail.MailSender mail = new MailSender();
mail.EmailSender();
}
都是因为 Azure 不支持电子邮件触发器。我创建了上面的 Web 应用程序来发送 smtp 电子邮件并作为云服务发布到 Azure。每个星期五都应该发送一封电子邮件,其中包含来自候选人表的本周记录。安排电子邮件的任何事情都会有所帮助,但我认为我不能选择 SendGrid。
【问题讨论】:
-
您可以在
NewCandidates()方法中添加一些日志记录,以查看它在托管在 Azure 中时是否被调用?这很可能也与您的邮件服务器端的权限有关 - 从其他域的中继可能被禁用或某些防火墙设置。 -
放置一些日志的最简单方法是什么?
-
您的应用程序是在虚拟机 (IaaS) 还是云服务 (PaaS) 中运行?理想的解决方案是使用 Windows Azure 诊断。一个快速而肮脏的解决方案是将消息放入队列或 blob 中。
-
在云服务上运行。好的,我会去 Azure 诊断并让你知道
-
使用了 SendGrid。已排序。
标签: email iis azure scheduled-tasks global-asax