Hi I have created a azure function httptrigger to read a blob from blob storage with blob input bindings.
below is the function.json:
{
"disabled": false,
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"name" : "blobContent",
"type": "blob",
"direction": "in",
"path": "containerName/{id}.{extn}",
"connection": "AzureWebJobsStorage"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
]
}
and the index.js file is :
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.id || (req.body && req.body.id)) {
context.res = {
body : {'data' : context.bindings.blobContent},
headers : {'Content-type': 'application/xml"'}
}
}
else {
context.res = {
status: 400,
body: "Please pass a object/chuck id on the query string or in the request body"
};
}
context.done(null,context.res);
};
I am using both get and post method to call the httptrigger. Since i am using blob input binding, the content is retrieved before processing index.js. With this, i couldn't validate whether the API called with id and extn. Is there a way to handle the exception and give a message back to the API caller to pass the necessary parameters. Thanks in advance.