How to ensure only one Azure Functions Event Grid Trigger instance is allowed to run at at time?

ddx1 171 Reputation points
2020-10-25T00:28:19.933+00:00

I have several Event Grid Triggers using Python on the Linux Consumption Plan that are executed when new blobs are created in Azure Storage. It's possible for more than one function instance to run simultaneously if blobs are created at or around the same time. For instance I have two event triggers that look for blobs created with the following format:
Trigger 1

  "subjectBeginsWith": "/blobServices/default/containers/client1",
  "subjectEndsWith": ".txt"

Trigger 2

  "subjectBeginsWith": "/blobServices/default/containers/client2",
  "subjectEndsWith": ".txt"

If two blobs are created at the same time, I want to limit Azure Functions to only run one application (it doesn't matter which one) at a time to prevent memory issues. This scenario is fairly rare so I'm considering using the preview setting WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT to only allow one invocation to run at a time. Would this work or is there a better way?

I have another issue where it's possible for multiple blobs to be created at around the same time per client and I only care if one is processed per day. For example client 1 could have the following files created in a day:

client1/file1_20201024.txt
client1/file2_20201024.txt
client1/file3_20201024.txt

I only care if one file is created a day. I can create special exception handling in the code to see if the work was completed and then have the Python script return, but I'm wondering if there is a built in setting in Event Grid to handle cases like this. I.e., if three blobs are created within one minute, only create one event instead of three.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,263 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,687 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,427 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
314 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful