- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个名为 POEditorTranslations 的 Azure 函数,其 TimeTrigger 设置为:
* */10 * * * *
首先是公共(public)静态异步任务 POEditorTranslations...。它向正在等待的外部 API 发出了多个请求。我注意到它被一遍又一遍地执行,没有遵守上面每 10 分钟运行一次的间隔。
所以我将其重新制作为一个非常基本的非异步函数,而不是只记录(如下面的代码),但它仍然一遍又一遍地运行?!
函数如下所示:
[FunctionName("POEditorTranslations")]
public static void POEditorTranslations([TimerTrigger("%POEditorSchedule%")] TimerInfo myTimer, ILogger log, Microsoft.Azure.WebJobs.ExecutionContext context) //https://arminreiter.com/2017/02/azure-functions-time-trigger-cron-cheat-sheet/
{
IConfigurationRoot config = new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
log.LogInformation($"POEditorTranslations TESTING function executed at: {DateTime.Now}, POEditorSchedule: {config.GetValue<string>("POEditorSchedule")}");
}
所以它应该每 10 分钟运行一次,但它却一遍又一遍地运行?!执行后立即重新开始。
注意:在我的 Visual Studio 中本地运行它可以工作,但我有一个 Azure 中不存在的 local.settings.json 文件。
仍然如您所见,我记录了配置键“POEditorSchedule”的值,它对我来说看起来是正确的。
我做错了什么?
下面的日志显示了很多重新开始的行:
2023-08-24T08:30:00Z [Verbose] Timer for 'POEditorTranslations' started with interval '00:00:00.8937384'.
2023-08-24T08:30:01Z [信息] 正在执行“POEditorTranslations”(原因=“计时器于 2023-08-24T08:30:00.9949394+00:00 触发”,Id= 7a0544f4-4a28-44a4-a379-2a441edb0d82)
2023-08-24T08:30:01Z [信息] POEditorTranslations TESTING 函数执行于:8/24/2023 8:30:00 AM,POEditorSchedule: * */10 * * * *
2023-08-24T08:30:01Z [信息] 执行“POEditorTranslations”(成功,Id=7a0544f4-4a28-44a4-a379-2a441edb0d82,持续时间=1ms)
2023-08-24T08:30:01Z [详细] 函数“POEditorTranslations”更新状态:Last='2023-08-24T08:30:01.0000000+00:00',Next='2023-08-24T08:30 :02.0000000+00:00',LastUpdated='2023-08-24T08:30:01.0000000+00:00'
2023-08-24T08:30:01Z [详细]“POEditorTranslations”计时器以间隔“00:00:00.9871280”开始。
2023-08-24T08:30:02Z [信息] 正在执行“POEditorTranslations”(原因=“计时器于 2023-08-24T08:30:01.9988546+00:00 触发”,Id= 003f08fc-92de-4509-8fc3-fe97a0813346)
2023-08-24T08:30:02Z [信息] POEditorTranslations TESTING 函数执行于:8/24/2023 8:30:01 AM,POEditorSchedule: * */10 * * * *
2023-08-24T08:30:02Z [信息] 执行“POEditorTranslations”(成功,Id=003f08fc-92de-4509-8fc3-fe97a0813346,持续时间=1ms)
2023-08-24T08:30:02Z [详细] 函数“POEditorTranslations”更新状态:Last='2023-08-24T08:30:02.0000000+00:00',Next='2023-08-24T08:30 :03.0000000+00:00',LastUpdated='2023-08-24T08:30:02.0000000+00:00'
更新
我得到了有关在 Azure 门户中使用环境变量而不是配置的答案 - 但我没有这样的菜单项:
最佳答案
我已在我的环境中重现了该问题,但在将 Cron 表达式更新为 0 */10 * * * *
后,我的函数每 10 分钟就开始按预期工作
代码:
[FunctionName("POEditorTranslations")]
public void Run([TimerTrigger("%POEditorSchedule%")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"POEditorTranslations TESTING function executed at: {DateTime.Now}");
}
本地运行时-
local.settings
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"POEditorSchedule": "0 */10 * * * *"
}
}
本地输出:
部署后,我已将 POEditorSchedule
添加到应用设置 -
输出:
第一次触发-
第二次触发-
关于Azure Function TimeTrigger 一遍又一遍地运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76967528/
我目前无法在使用 Function CLI 版本 2.3.148 和 2.3.199 的 macO 中运行 TimeTrigger 函数: 这是我的 csproj: netstanda
我有一个名为 POEditorTranslations 的 Azure 函数,其 TimeTrigger 设置为: * */10 * * * * 首先是公共(public)静态异步任务 POEdito
我有一个在 Linux 系统中运行的 azure 函数应用程序。在其中,我创建了两个函数,一个由 blob 触发器触发,另一个由 timetrigger 触发。 这两个功能都是通过azure DevO
我正在尝试创建一个 Azure WebJob,它将在设定的计时器上执行 Functions.Methods。我在 VS2017 中设置了一个简单的 WebJob 项目,并添加了 Microsoft.A
我已遵循 Microsoft 指南创建和注册后台任务:https://msdn.microsoft.com/en-us/library/windows/apps/mt299100.aspx 我有我的主
当我尝试从“新解决方案”模板创建“计时器触发器”应用程序时,Visual Studio Professional 2022(创建新项目 -> Azure Functions -> 计时器触发器)会创建
当我尝试从“新解决方案”模板创建“计时器触发器”应用程序时,Visual Studio Professional 2022(创建新项目 -> Azure Functions -> 计时器触发器)会创建
在我的 UWP 应用程序中,我有一个由 TimeTrigger 触发的后台任务。在后台任务的代码中,我有这个片段(我的示例中的“第一个事件”和“第二个事件”几乎不消耗任何资源): var deferr
在我的 Windows 8 Metro 应用程序的后台任务中运行时,Client.GetAsync 对我来说似乎失败了。 我尝试同时使用 TimeTrigger 和 MaintenanceTrigge
我发现使用 TimeTrigger 是 Windows 10 (UWP) 上计划后台任务的方式。但是看起来我们需要给出的最小数字是 15 分钟。只是想知道,即使我们安排它在接下来的 1 分钟内运行,警
这是我的场景:我在同一个解决方案中有一个 Windows Phone 8.1 应用程序 (MainApp)、一个类库和一个 Windows 运行时组件 (BackgroundTask)。 当我加载我的
我已在 Visual Studio Code 中成功创建了 Azure 时间触发器。 我在上传到 Azure 门户之前在 VSC 中对其进行了测试,并且运行正常 当我在 Azure 中运行它时,它给我
我已在 Visual Studio Code 中成功创建了 Azure 时间触发器。 我在上传到 Azure 门户之前在 VSC 中对其进行了测试,并且运行正常 当我在 Azure 中运行它时,它给我
我是一名优秀的程序员,十分优秀!