【Azure 应用服务】Azure Function Timer触发函数加上Singleton后的问题

简介: 【Azure 应用服务】Azure Function Timer触发函数加上Singleton后的问题

问题描述

在Azure Function Timer Trigger的函数中,添加了Singleton属性,当Function的实例变为3个后,发现Timer函数并没有在三个实例上同时运行,每次触发时,都只有在一个实例上运行。这时因为Singleton属性的原因吗?

问题解答

在调查Singleton属性中,确实有描述 Singleton 单例模式,保证Function 在多个实例中,只会在一个实例上运行。详见:https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute

The Singleton attribute ensures that only one instance of a function runs, even when there are multiple instances of the host web app. The Singleton attribute uses distributed locking to ensure that one instance runs.

但是,在深入产看Function Timer 触发器的文档后,发现Timer 函数只会单实例运行。不存在并发情况!

 

通过实验测试,在没有使用Singleton属性的情况下,Timer函数只在一个实例上运行!

 

 

参考资料

WebJob / Function Singleton attribute : https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#singleton-attribute

Azure Functions 的计时器触发器 横向扩展 : https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp#scale-out

 

相关文章
|
22天前
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
|
22天前
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
|
22天前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
22天前
|
Python
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表
【Azure Function】发布 Python Function 到 Azure 成功,但是无法显示Function列表
|
22天前
|
C#
【Azure Function】Function App启动时出现 Failed to open local port 4001 错误,这是什么情况呢?
【Azure Function】Function App启动时出现 Failed to open local port 4001 错误,这是什么情况呢?
|
22天前
|
C# C++
【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found
【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found
|
22天前
【Azure Function & Application Insights】调用Function上传和下载文件,有时候遇见大于1MB的文件的日志没有记录在Application Insights中
【Azure Function & Application Insights】调用Function上传和下载文件,有时候遇见大于1MB的文件的日志没有记录在Application Insights中
|
22天前
|
API C++ Python
【Azure Function】示例运行 python durable function(model V2)
【Azure Function】示例运行 python durable function(model V2)
|
22天前
|
C++
【Azure Function App】在VS Code中,创建好Function App后部署到Azure中,无法选择Subscriptions
【Azure Function App】在VS Code中,创建好Function App后部署到Azure中,无法选择Subscriptions
|
22天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.

热门文章

最新文章