I am using an Azure function as Webhook Consumer to receive http events as JSON and storing it on Azure Storage. I want to do Dynamic naming of the output blob path based on date as shown below. I tried lots of options, but not able to get the desired output. I am followed this post but no luck.
Excepted write path:
source/
ctry/
yyyy/
mm/
date/
hrs/
event_{systemtime}.json
function.json:
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
},
{
"type": "blob",
"name": "outputblob",
"path": "source/ctry/{datetime:yyyy}/{datetime:MM}/{datetime:dd}/{datetime:hh}/event_{systemtime}.json",
"direction": "out",
"connection": "MyStorageConnectionAppSetting"
}
]
}
init.py
import logging
import azure.functions as func
def main(req: func.HttpRequest,outputblob: func.Out[str]) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = 'some_name'
if not name:
try:
req_body = 'req_body_test'#req.get_json()
except ValueError:
pass
else:
name = 'name'#req_body.get('name')
print(str(req.get_json()))
outputblob.set(str(req.get_json()))