0

I'm facing a problem with an Azure Function.

I've build an Azure Function triggered by a new file on a container of a storage account. The problem is that it seems impossible (to me) to trigger the function with a generic file, without specifing a name!

I've searched on official documentation and it's not specified how to reference a generic file. The expected behaviour is to have a function triggered when I upload any file (with any name) in a specific container, something like "container/*".

This is my simple function:

function.json

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "inputBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "premium-input/*",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

init.py

import logging
import azure.functions as func


def main(inputBlob: func.InputStream):
    logging.info("START EXECUTION")
    logging.info(f'NAME {inputBlob.name}')
    logging.info(f'URI {inputBlob.uri}')
    logging.info("END EXECUTION")

I've already tried using an event on EventGrid, but I prefer avoiding it...

Can you please help me?

Thanks in advance!!

3
  • As currently configured it should be triggered when a blob is uploaded to the premium-input container in the specified storage account Commented May 24, 2023 at 17:37
  • 1
    Have you tried to set the path to "path": "premium-input/{name}". I didn't find any documentation which says to set it to /*. Commented May 25, 2023 at 4:05
  • @PeterBons This would be the expected behavious, but this is actually the problem: with the configuration above the function is never triggered Commented May 25, 2023 at 8:45

1 Answer 1

2

I have tried to upload generic files to a container as below and my function got triggered. If you will change the path premium-input/* to premium-input/{name} , it will work.

init.py

import logging
import azure.functions as func
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"URI: {myblob.uri}\n"
f"Blob Size: {myblob.length} bytes")

function.json

{
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "demo/{name}",
"connection": "your connection string"
}
]
} 

Container- enter image description here

Logs- enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! Actually I had another problem that masked the correct behaviour, the Log Stream didn't update. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.