Blob version information in blob trigger

200 Views Asked by At

I currently work on a blobtrigger that gets triggered everytime a blob has been created, a new version of a blob has been uploaded (so a blob has changed) or an blob got deleted. So my base implementation looks something like this:

[FunctionName("SomeTriggerFunction")]
public void Run([BlobTrigger("container-name/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob, 
                string name, ILogger log, ExecutionContext executionContext)
{
     // do some stuff with the blob
}

The idea is to get the blobs version information and store them into another datasource. The simpliest way to retrieve the blob version information is to use the functions "name" parameter, send a request to the blob storage and retrieve the version information. But this feels a little odd as I have to access the storage again.

So my question is, is there a smarter way to retrieve the blob version information directly within the trigger? Some attribute? Another trigger definition?

1

There are 1 best solutions below

1
On

You need to enable the versioning in blob storage after that you can directly check for the version as each blob will have a unique versionId which you can store after wards.

refer the following documentations