0

I have created a blobtrigger that runs whenever i upload to my container. But since i am going to use kraken to process the image, and then reupload the processed images in a subfolder of the original image.

I am unable to figure out how to make sure that i am not going to trigger on kraken uploading images to the container..

Folder setup

  • Foldername
    • file.jpg
    • file.jpg

Kraken uploads to the folder (krakenfolder)

  • foldername

    • file.jpg
    • file.jpg

    • krakenfolder

      • krakenprocessedimage.jpg
      • krakenprocessedimage.jpg

Currently my blobtrigger also triggers on subfolders.. how can check for it or stop it from doing this?

My blobtrigger as it is currently

[FunctionName("ProductBlobDispatch")]
        public static async void Run(
            [BlobTrigger("products/{name}")]
            Stream myBlob,
            string name,
            ILogger log,
            string blobTrigger,
            [Queue("scanpipe-media-dispatch")] IAsyncCollector<MediaDispatchModel> imageProcessor)
        {
            log.LogInformation($"Blob trigger on product upload, processed blob\n Name: {name}\n Size: {myBlob.Length} Bytes");

            //convert stream to model.

            var model = new ImageProcessingModel()
            {
                Url = "/"+name,
                IsProduct = true,
                IsDeleted = false,
            };

            await imageProcessor.AddAsync(model);
        }
andrelange91
  • 1,018
  • 3
  • 21
  • 48

2 Answers2

2

As blob storage does not have "physical" folders, there is no way. Everything in name is part of the blob in the same flat structure. Even if the name is my/first/level/virtual/folder/text.txt

So you have to filter it out in your code or use containers as your "folder".

To add: There are limited filter capabilities but none of those do seem to apply to what you are looking for.

silent
  • 14,494
  • 4
  • 46
  • 86
0

I do not know it if is the best way of doing it, but it works for me.

I check on '/' with

name.Count(x => x == '/') > 1
andrelange91
  • 1,018
  • 3
  • 21
  • 48