azure - 获取上次运行 Azure 函数的时间

标签 azure azure-functions

在 Visual Studio 2017 中,我创建了一个新的 Azure Function 项目,该项目生成了以下代码:

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;

namespace FunctionApp1
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
        {
            var lastRun = myTimer.ScheduleStatus.Last;

            log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

我的问题是关于 lastRun 变量的。是吗:

  1. 函数上次成功运行的时间
  2. 函数上次运行的时间,无论成功还是失败
  3. 完全是别的东西

我搜索了 Azure 文档,但未能找到有关 TimerInfo 对象属性的任何信息,因此了解此变量是否可用于了解函数上次运行时间会很有帮助。

最佳答案

TimerInfo 对象的 ScheduleStatus 上的“Last”属性是上次函数计时器触发时的日期时间,无论函数运行状态是成功还是失败。当定时器触发时,它会触发定时器函数执行。

关于azure - 获取上次运行 Azure 函数的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55939498/

相关文章:

python - 在本地运行使用 Python 创建的 Azure Functions 时出错,Func Start 不会失败

azure - 将 Azure Functions 部署到多个函数中的特定函数而不覆盖其他函数

python-3.x - 从 Function App 读取 Azure Key Vault Secret

.net - RouteTable.Routes.MapHubs() 仅在 Windows Azure 模拟器中抛出 ArgumentNullException。为什么?

azure - Azure WebJobs SDK 作业的默认超时是多少?

Azure API 应用程序问题 - 身份验证

javascript - 在 azure 函数内发出 https 请求

azure - 如何修复发布 Azure Functions 时出现的 "Validate Connection"错误“找不到 testMsDeployConnection”?

azure函数无法从appsettings读取消费者组名称

azure - 从 terraform Output 获取数据并将其用作输入