Search code examples
azure-functionsazure-blob-storageazure-blob-trigger

How to make Azure function trigger only for files, not for folders?


I have a Azure Function set up like this.

{
  "scriptFile": "identifier.py",
  "bindings": [
    {
      "name": "blob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "customers/{blob}",
      "connection": "DL_GEN2_STORAGE"
    }
  ]
}

The problem that I have is that the function triggers for folders as well as files, that are created in the blob storage.

Can one specify that it only triggers for files an not for folders?


Solution

  • If anyone is interested. The problem that I had was that folders would throw errors when triggering the Azure function, because it was an unknown data type to the function. My current solution is to check the size of the blob.

    def main(blob: func.InputStream):
    
        if blob.length is None:
            logging.info("The blob has no data in it.")
            logging.info("The blob is most likely a folder.")
            return
    

    This way it does at least not throw an error when creating folders in the blob storage.