Azure Function is not getting triggered - Blob Storage Trigger

0

I have a simple Azure Function that is triggered when a new item is added in a Blob Storage.

The function reads the new JSON file uploaded to the Blob Storage and loads the information in a DataBase.

It works locally and when I deployed the function it was also working as expected, but when I checked the data a few days later I discovered the function did not get trigger. The function app, however, showed the status "running". I restarted the app and it began to upload data again, just to stop a few hours later.

It seems to only be working when I restart the app or when I open Azure Functions in the browser.

Some additional data:

I'm adding some information that I think might be relevant, but I'm new to Azure Functions so if there is any more important information I am overlooking feel free to ask for it. I have Application Insights monitoring the app as well.

Runtime version: 3.0.15571.0

Mode: Consumption

1. Application Insights check

I checked the requests in the last 3 days. It worked the same hours that I spent yesterday trying to figure out what was wrong. There were a lot of request because it was catching up with all the old files that werent processed: enter image description here

The last request was yesterday, as we can check in the query: enter image description here

2. kudu check

The logs I am watching are the expected ones that I coded into my function, some unexpected ones that I dont know the meaning of, and some errors on my SQL connection:

The information shown is the following:

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

Where the last line is the log that the execution of the function writes. I am also getting some errors on my SQL connexion that didn't occur when I tested it:

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
azure
azure-functions
azure-functions-runtime
azure-blob-trigger
asked on Stack Overflow Apr 26, 2021 by Teresa Rey Alonso • edited Apr 27, 2021 by Teresa Rey Alonso

1 Answer

0

It seems to only be working when I restart the app or when I open Azure Functions in the browser.

This situation should not occurred. How do you determine this?

Please use below two ways to check:

1, Use Application Insights:

Go to your Application Insights, and run:

requests

And please don't forget to set the time range:

enter image description here

2, Use kudu:

Directly go to the https://yourfunctionappname.scm.azurewebsites.net/DebugConsole, and click to \home\LogFiles\Application\Functions\Function\yourtriggername

Please check the logs, maybe you can find something.

answered on Stack Overflow Apr 27, 2021 by Bowman Zhu • edited Apr 27, 2021 by Bowman Zhu

User contributions licensed under CC BY-SA 3.0