【Azure Function App】本地运行的Function发布到Azure上无法运行的错误分析
问题描述
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
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2020-12-19 【Azure Redis 缓存】Azure Redis读写比较慢/卡的问题排查
2020-12-19 【Azure 服务总线】向服务总线发送消息时,返回错误代码Error code : 50009