Azure function blob trigger for subfolders

2.8k views Asked by At

I have a container folder where there are many sub-folders(around 3000), a file can land in any of the sub-folders. I need to react to a blob that's added into a sub-folder. I still can't figure out how to create a blob trigger if files are added to sub-folders.

Example:

Excerpt from function.json: 
{
    "name": "myblob",
    "type": "blobTrigger",
    "direction": "in",
    "path": "rootContainer/{name}"
}

OK, a function is triggered if I receive the blob in rootContainer folder

Except from function.json: 
{
    "name": "*/myblob",
    "type": "blobTrigger",
    "direction": "in",
    "path": "rootContainer/{name}"
}
or 
{
    "name": "myblob",
    "type": "blobTrigger",
    "direction": "in",
    "path": "rootContainer/*/{name}"
}

NOT OK, a function isn't triggered

There are not many questions regarding this problem and they still don't provide a normal answer. Can't find any info in documentation either.

Thanks!

1

There are 1 answers

3
Cindy Pau On

I notice you use */myblob as the name, but this is no use.

For example, if you want the function be triggered when something send to a folder such as test under rootContainer, you need to use this function.json:

{
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "rootContainer/test/{name}",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

The path needs to be defined at compile time.