简体   繁体   English

如果 function 的实例已经在执行,定时器触发的 Azure function 是否会执行?

[英]Does a timer-triggered Azure function execute if an instance of the function is already executing?

I have an Azure Function App with the [TimerTrigger(...)] attribute, which is scheduled to execute every morning.我有一个带有[TimerTrigger(...)]属性的 Azure Function 应用程序,计划每天早上执行。

Suppose you manually execute the function via the Function Menu Blade -> Code + Test -> Test/Run, as shown at the bottom of this message.假设您通过 Function 菜单刀片 -> 代码 + 测试 -> 测试/运行手动执行 function,如该消息底部所示。 What happens if this manual execution of the function is still running when the time specified in the TimerTrigger attribute arrives?如果在TimerTrigger属性中指定的时间到达时,手动执行 function 仍在运行,会发生什么情况?

  1. Will the manual execution be interrupted by the timer-triggered execution?手动执行会被定时器触发的执行打断吗?
  2. Will the manual execution prevent the timer from triggering a new execution of the function?手动执行是否会阻止计时器触发 function 的新执行?
  3. Or will a new instance of the function be kicked off when the timer triggers it, running in parallel with the existing manual execution?或者当计时器触发它时,function 的新实例是否会被启动,与现有的手动执行并行运行?

在此处输入图像描述

You can run the same azure function at the same time.您可以同时运行相同的 azure function。 You can add a bool if you want to prevent the execution of the azure function if it is currently running:如果要阻止 azure function 当前正在运行,则可以添加一个布尔值:

public class AzureFunction()
{
   private static bool _isRunning = false;

   [FunctionName("Function1")]
   public async Task Run([TimerTrigger("0 30 9 * * *")] 
      if (_isRunning)
      {
         //an instance is already running, lets not continue
         return;
      }
      _isRunning = true;

   //work is being done

   //after work is done
   _isRunning = false;
}

Say you have a Timer that goes off every minute, but your code takes 2 minutes to run.假设您有一个每分钟都会关闭的计时器,但您的代码需要 2 分钟才能运行。 The timer will kick off every minute regardless of if the previous run is done or not.无论之前的运行是否完成,计时器都会每分钟启动一次。

If you set your TimerTrigger to run at a daily time, a manual run will not interrupt or cause an issue to your daily run but you can still do a manual run during your timed trigger .如果您将 TimerTrigger 设置为每天运行,手动运行不会中断或导致日常运行出现问题,但您仍然可以在定时触发期间进行手动运行 Example of the one above will run every day at 9:30am.上述示例将在每天上午 9:30 运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 定时器触发的 function 在 Azure function 应用程序(C#) - Timer-triggered function in Azure function app (C#) 计时器触发的Azure功能未在计划的时间触发,并且因Azure存储超时异常而失败 - Timer-triggered Azure Function not triggered on scheduled time and failed with Azure storage timeout exception 在本地运行一次计时器触发的 Azure 函数的最简单方法是什么? - What is the simplest way to run a timer-triggered Azure Function locally once? 如何在计时器触发的函数上强制执行单例行为? - how to enforce singleton behavior on a timer-triggered function? 具有定时器触发的 Azure 功能的令牌缓存 - Token Cache with Timer-Triggered Azure Functions 如何调用 http 触发 azure function 从定时器触发 azure function - How to call http triggered azure function from timer triggered azure function 定时器触发单元测试 Azure Function:提供测试数据 - Unit Tests for timer triggered Azure Function: provide test data Azure function 未由 EventHubTrigger 触发 - Azure function not triggered by EventHubTrigger Azure function 定时器触发器 - Azure function timer trigger 是否可以通过顺序执行来执行 Azure 函数定时器触发器? - Is it possible to execute Azure function Timer trigger with Sequential Execution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM