Starting Host (HostId=funapp-xxx-dev, Version=1.0.20776.0, InstanceId=xxx-x-xx-x-xxx, ProcessId=7924, AppDomainId=2, Debug=True, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=~1)

问题描述

Azure Function部署后未执行,查看日志发现错误信息:

2023-12-19T11:12:27.145 [Verbose] Host configuration applied.
2023-12-19T11:12:27.237 [Info] Starting Host (HostId=funapp-xxx-dev, Version=1.0.20776.0, InstanceId=xxx-x-xx-x-xxx, ProcessId=7924, AppDomainId=2, Debug=True, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=~1)
2023-12-19T11:12:27.102 [Verbose] Debug file watch initialized.
2023-12-19T11:12:27.222 [Verbose] File event source initialized.
2023-12-19T11:12:28.233 [Verbose] Function metadata read.
2023-12-19T11:12:28.345 [Verbose] Binding providers loaded.
2023-12-19T11:12:29.052 [Verbose] Binding providers initialized.
2023-12-19T11:12:29.052 [Info] Loaded custom extension 'BotFrameworkConfiguration'
2023-12-19T11:12:29.064 [Info] Loaded custom extension 'SendGridConfiguration'
2023-12-19T11:12:29.082 [Info] Loaded custom extension 'EventGridExtensionConfig'
2023-12-19T11:12:29.335 [Warning] Failed to load type 'xxxxx.xxxxx.xxxxx-1' from 'C:\home\site\wwwroot\bin\xxxxx.xxxxx.dll'
2023-12-19T11:12:29.335 [Warning] Failed to load type 'xxxxx.xxxxx.xxxxx-1' from 'C:\home\site\wwwroot\bin\xxxxx.xxxxx.dll'
2023-12-19T11:12:29.345 [Verbose] Extension loading complete.
2023-12-19T11:12:31.127 [Info] registered EventGrid Endpoint = https://funapp-export-dev.chinacloudsites.cn/admin/extensions/EventGridExtensionConfig
2023-12-19T11:12:31.847 [Verbose] Metadata provider created.
2023-12-19T11:12:32.407 [Verbose] Function descriptors read.
2023-12-19T11:12:32.407 [Info] Generating 0 job function(s)
2023-12-19T11:12:32.845 [Verbose] Development settings applied
2023-12-19T11:12:32.845 [Warning] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
2023-12-19T11:12:33.423 [Info] Host initialized (6699ms)
2023-12-19T11:12:33.486 [Info] Host started (6761ms)
2023-12-19T11:12:33.486 [Info] Job host started
2023-12-19T11:12:33.552 [Error] The following 2 functions are in error:
ExportJob: The function type name 'xxxxx.xxxxx.xxxxx-1' is invalid.
RemoveBlobJob: The function type name 'xxxxx.xxxxx.xxxxx-1' is invalid.
2023-12-19T11:12:33.708 [Info] Host lock lease acquired by instance ID 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.

 

问题解决

在日志中,发现Function Host的Version=1.0, 这是非常老的Function Runtime Version。 而本地使用的 3.0 版本,所以从这一点判断出是版本问题导致。
需要通过设置 FUNCTIONS_EXTENSION_VERSION 参数,来指定版本信息。

 

 

参考资料

How to target Azure Functions runtime versions: https://learn.microsoft.com/en-us/azure/azure-functions/set-runtime-version?tabs=portal#automatic-and-manual-version-updates 

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!