监控 Azure WebJob 和 Function App 故障

Monitoring Azure WebJob & Function App Failures

我目前担任一家公司的 SharePoint 管理员,该公司有一些代码工作(WebJobs 和 Function Apps 的混合)运行在 O365 网站的后台执行一些杂项任务,例如确保webhook 子仍处于活动状态,克隆站点,并使用 SharePoint 中表单中的信息填充克隆。

这些工作是关键任务,因为它们与危机管理网站相关联,所以我被要求进行一些监控,以确保在任何失败时我们都会收到警报,无论是作为计划的一部分还是在-需求(又是这些的混合)。

问题是我不太了解 Azure,除了它取代了 SP 中的农场解决方案作为 运行 后端代码的地方,尤其是对于那些有太多名称的东西在我看来非常相似。

任何人都可以推荐一种简单的方法,我可以为单个 web 作业和函数设置某种监视触发器以防止失败,理想情况下只需使用内置的 Azure 控制面板(即无需部署任何代码 - 我'我真的不是 C# 之类的编码员)。

对于Function和webjob,你们都可以使用Application Insight来监控它们。

对于功能,Ivan 已链接官方文档:Monitor Function, and for webjob official doc actually has a tutorial about configuring Application Insight:Add Application Insights logging

您还可以参考 关于使用 Application Insight 的内容。使用此包:Microsoft.Azure.WebJobs.Logging.ApplicationInsights 并添加 JobHostConfiguration。

    string instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
    if (!string.IsNullOrEmpty(instrumentationKey))
    {
          // build up a LoggerFactory with ApplicationInsights and a Console Logger
           config.LoggerFactory = new LoggerFactory().AddApplicationInsights(instrumentationKey, null).AddConsole();
           config.Tracing.ConsoleLevel = TraceLevel.Off;
    }

然后您就可以添加网络作业日志了。希望对你有帮助。