只有一个 Azure Functions 实例?

Only have one instance of an Azure Function?

我找不到任何关于如何将 Azure Function v4 强制为单例的文档,因此当函数应用程序横向扩展时(出于某些原因),其中一个函数没有横向扩展。

我的函数是一个 TIMER TRIGGER,在 v4 .NET6.0 ISOLATED Azure 函数中。

即使您的 Function App 横向扩展计时器触发器也只会 运行 在单个实例上。

If a function app scales out to multiple instances, only a single instance of a timer-triggered function is run across all instances. It will not trigger again if there is an outstanding invocation is still running.

Microsoft docs

documentation shows direct creation of .net 6 in Azure functions v4 in Visual Studio and this is for working with VS code to the same .Net 6 Azure Functions V4 and this documentation 可帮助您通过命令行使用 Azure Functions v4 和 .Net Core 6。

I can't find any documentation on how to force an Azure Function v4 into a singleton, so as the function app scales out (for reasons), one of the functions doesn't scale out.

如果一个函数应用程序扩展到多个实例,则在所有实例中只有定时器触发函数的一个实例 运行。如果有未完成的调用仍在运行ning.

,则不会再次触发

请参考这个MSFT documentation for more details and this GitHub thread