0
votes

For the last 14 months, I've had an Azure Function running without issues. It uses a BlobTrigger to run whenever a new blob is created in a Blob Storage Container. Blobs are created very intermittently, so the Function almost exclusively relies on cold starts (latency is no concern). However, as of a weeks ago, the BlobTrigger no longer initiates a cold start (as in, 3 days later the Function still hadn't run). But when I access the Function in portal.azure to wake it up, BlobTrigger does fire once for each blob in the storage.

The interesting thing is that I haven't made any changes to this Function in at least 6+ months, so I'm struggling to identify the cause.

About the Azure Function:

  • Consumption plan
  • Runtime version 3.2.0.0
  • Blob Storage trigger
  • I deploy using Java/Maven
  • Function code (Trigger)
  @FunctionName("veninv")
     public void blob(
      @BlobTrigger(
      name = "blob",
      dataType = "binary",
      path = "veninv-prod/{name}",
      connection = "AzureWebJobsStorage") 
      byte[] content,
      @BindingName("name") String blobname,
      final ExecutionContext context
      )

AzureWebJobsStorage is an application setting containing the connection string to a StorageV2 account.

Expected behaviour: When a new blob is created in the specified storage container, the Function's BlobTrigger initiates a cold start and wakes up the Function.

Actual behaviour: When a new blob is created, the Function's BlobTrigger doesn't initiate a cold start. Instead, the Function must be woken up manually in portal.azure after which the BlobTrigger will fire once for each blob.

Things I have done so far:

  • "Diagnose and solve problems" shows no errors in my Function.
  • I have confirmed the Function is set to a Consumption plan
  • I restarted the Function App
  • I have done an HTTP POST request to sync the trigger
  • I enabled Scale Controller logging, which shows the following four logs after the Function last ran:

2021-10-14T20:35:11.0707779Z Adding or updating trigger. {"Category":"ScaleControllerLogs","AppName":"veninv-Prod","Timestamp":"2021-10-14T20:35:11.0707779Z","TriggersHash":"35243DA6","SlotName":"Production","FunctionName":"veninv","Action":"RefreshTrigger","TriggerUpdated":"[{"connection":"AzureWebJobsStorage","functionName":"veninv","path":"veninv-prod\/{name}","dataType":"binary","type":"blobTrigger","direction":"in","name":"blob","useMonitor":null}]"}

2021-10-14T20:35:11.0707779Z Created CloudStorageAccount with ConnectionString. {"Category":"ScaleControllerLogs","AppName":"veninv-Prod","Timestamp":"2021-10-14T20:35:11.0707779Z","TriggersHash":"35243DA6","SlotName":"Production","FunctionName":"veninv","Action":"TriggerInformation"}

2021-10-14T20:58:41.7386529Z Instance count changed {"Category":"ScaleControllerLogs","AppName":"veninv-Prod","Timestamp":"2021-10-14T20:58:41.7386529Z","SlotName":"Production","Action":"ScaleResult","Reason":"An instance was removed because all functions are either idle or seeing a steady decrease in load.","CurrentInstanceCount":"0","PreviousInstanceCount":"1"}

2021-10-14T20:58:41.7386529Z App is no longer assigned to any instance and may idle out at any time. {"Category":"ScaleControllerLogs","AppName":"veninv-Prod","Timestamp":"2021-10-14T20:58:41.7386529Z","SlotName":"Production","Action":"TriggerInformation","FunctionName":"N/A","TriggersHash":"35243DA6"}

1

1 Answers

0
votes

According to this document cold start is

phenomenon that applications which haven’t been used take longer to start up.

In consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events.

If you've written a heavy code and deployed on consumption plan which takes lot of memory and resources to get loaded to execute it may take more time. So the problem you are facing can be dependent on code, resources, function host.

As you are not getting any error to solve this problem instead of using Blob Triggers you might want to use Event Grid Triggers for this scenario. These events are triggered when a client creates, replaces, or deletes a blob by calling Blob REST APIs.