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!!
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-
Logs-