【Azure Function】Azure Function中的Timer Trigger无法自动触发问题

问题描述

在Azure Function中,部署了定时触发器函数(Timer Trigger),却无法按时触发。

 

问题解答

登录Function的Kudu站点,查看 logfiles中 application/function/host目录下的日志文件,发现错误消息:

Singleton lock renewal failed for blob 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/host' with error code 409: LeaseIdMismatchWithLeaseOperation. The last successful renewal completed at 2024-05-05T00:07:29.916Z (18845 milliseconds ago) with a duration of 48 milliseconds. The lease period was 15000 milliseconds.

这表示当前Function App不能从所绑定的Storage Account获取Lease,无法为Timer Trigger提供触发所需的Host ID / Lease ID信息。多个function app不建议用同一个storage account,因为function app都会在storage account中保存一个 host id,这个host id根据function app的名称来算的,如果function app 的名称长度大于32,就截取前32位。如果是一样的值,就会用同一个host id。导致出现争抢 Singleton Lock情况。

因为当前多个Function的确存在共用一个Stroage Account,并且名称长度超过32为,并且前32位的字符和其它Function App一样,所以引起了以上问题。在不能修改Function App的名字的情况下,通过修改位不同的Storage Account来解决了当前问题。

 

参考资料

AZFD0004:主机 ID 冲突:https://learn.microsoft.com/zh-cn/azure/azure-functions/errors-diagnostics/diagnostic-events/azfd0004#event-description

Host ID: https://learn.microsoft.com/zh-cn/azure/azure-functions/storage-considerations?tabs=azure-cli#host-id-considerations

posted @ 2024-05-08 20:20  路边两盏灯  阅读(8)  评论(0编辑  收藏  举报