function.json
{
"scriptFile": "__init__.py",
"disabled": false,
"bindings": [
{
"name": "blob",
"type": "blobTrigger",
"direction": "in",
"path": "{CONTAINERNAME}",
"connectionStringSetting": "BLOB_CONNECTION_STRING"
}
]
}
app/init.py
CONTAINERNAME =os.environ.get("CONTAINERNAME")
def main(blob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name:{blob.name}\n"
f"Blob Size: {blob.length} bytes")
I am required to pass the dynamic container name to function.json as it may change/update in the future so somehow I can pass it through the environment variable. I have tried different ways like
- %CONTAINERNAME%
- ${CONTAINERNAME}
- {CONTAINERNAME}
- "pathStringSetting": "{CONTAINERNAME}",
But I'm getting the same error: The 'app' function is in error: Unable to configure binding 'blob' of type 'blobTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call.
I passed the dynamic container name to function.json as %CONTAINERNAME%/{name} and successfully executed the blob trigger function.
Code :
function.json :
local.settings.json :
Output :
The following blob trigger function code successfully triggered the blob as shown below:
Azure Portal :
Below is the blob I sent to the samples-workitems container.