我有一个简单的 Azure 函数,当在 Blob 存储中添加新项目时会触发该函数。
该函数读取上传到 Blob 存储的新 JSON 文件并将信息加载到数据库中。
它在本地工作,当我部署该功能时,它也按预期工作,但是当我几天后检查数据时,我发现该功能没有被触发。但是,函数应用显示状态“正在运行”。我重新启动了应用程序,它再次开始上传数据,只是在几个小时后停止了。
它似乎只有在我重新启动应用程序或在浏览器中打开 Azure Functions 时才有效。
一些额外的数据:
我正在添加一些我认为可能相关的信息,但我是 Azure Functions 的新手,所以如果有任何更重要的信息我忽略了,请随时询问。我也有 Application Insights 监控应用程序。
运行时版本:3.0.15571.0
模式:消费
1. Application Insights 检查
我检查了过去 3 天的请求。它的工作时间与我昨天试图找出问题所在的时间相同。有很多请求,因为它正在赶上所有未处理的旧文件:
2.捻度检查
我正在查看的日志是我在函数中编码的预期日志,一些我不知道含义的意外日志,以及我的 SQL 连接上的一些错误:
显示的信息如下:
2021-04-26T17:50:23.377 [Information] Executing 'FunctionSaveOnBDD' (Reason='New blob detected: containerforiotcentral/c618a003-9934-4b25-a674-cd709b6afb07/4/2021/03/27/11/22/vliwcspeyze7a', Id=34a100dc-135f-41ed-ba7b-209d85f28b63)
2021-04-26T17:50:23.377 [Information] Trigger Details: MessageId: 0113b888-75f7-4cb8-b9cd-562255e34c56, DequeueCount: 1, InsertionTime: 2021-04-26T17:39:03.000+00:00, BlobCreated: 2021-03-27T11:23:53.000+00:00, BlobLastModified: 2021-03-27T11:23:53.000+00:00
2021-04-26T17:50:23.378 [Information] Executing 'FunctionSaveOnBDD' (Reason='New blob detected: containerforiotcentral/c618a003-9934-4b25-a674-cd709b6afb07/4/2021/03/27/11/21/vliwcspeyze7a', Id=5e7ee513-346d-45d4-a8a4-b2f981ed470a)
2021-04-26T17:50:23.378 [Information] Trigger Details: MessageId: 7525894a-ba7c-47b9-802a-54faa60a603a, DequeueCount: 1, InsertionTime: 2021-04-26T17:39:03.000+00:00, BlobCreated: 2021-03-27T11:22:53.000+00:00, BlobLastModified: 2021-03-27T11:22:53.000+00:00
2021-04-26T17:50:23.378 [Information] Executing 'FunctionSaveOnBDD' (Reason='New blob detected: containerforiotcentral/c618a003-9934-4b25-a674-cd709b6afb07/4/2021/03/27/11/23/vliwcspeyze7a', Id=e3d0ca32-2d07-4b18-8bb9-4edda7de68b5)
2021-04-26T17:50:23.378 [Information] Trigger Details: MessageId: b8bbd557-9710-4cea-81f7-7a243aa96111, DequeueCount: 1, InsertionTime: 2021-04-26T17:39:03.000+00:00, BlobCreated: 2021-03-27T11:24:53.000+00:00, BlobLastModified: 2021-03-27T11:24:53.000+00:00
2021-04-26T17:50:23.379 [Information] Executed 'FunctionSaveOnBDD' (Succeeded, Id=704c2ace-9688-40da-8aa7-a19190ece7c1, Duration=702ms)
2021-04-26T17:50:23.399 [Information] C# Blob trigger function Processed blob
Name:c618a003-9934-4b25-a674-cd709b6afb07/4/2021/03/27/11/04/vliwcspeyze7a
Content: telemetry
最后一行是函数执行写入的日志。我的 SQL 连接上也出现了一些在我测试时没有发生的错误:
2021-04-26T17:50:23.270 [Information] Microsoft.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 66) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at AzureFunctionBlobTrigger0103DEF.BlobTriggersaveonBDD.Run(Stream myBlob, String name, ILogger log) in C:\Users\Tere\source\repos\AzureFunctionBlobTrigger0103DEF\BlobTriggersaveonBDD.cs:line 52
ClientConnectionId:f46c83df-9566-4af9-866e-12728d39b646
Error Number:1205,State:18,Class:13
ClientConnectionId before routing:3f74ce3e-43a1-4c9c-8ddb-8e9c9d8610a9
Routing Destination:af4408adfd33.tr16.westeurope1-a.worker.database.windows.net,11040