I'm trying to upload a file via simple Azure function HTTPTrigger in JS and it gives me the following error:
[Error] Exception while executing function: Functions.HttpTriggerJS1. Microsoft.Azure.WebJobs.Host: Microsoft Azure WebJobs SDK '[Hidden Credential]' connection string is missing or empty. The Microsoft Azure Storage account connection string can be set in the following ways:
1. Set the connection string named '[Hidden Credential]' in the connectionStrings section of the .config file in the following format <add name="[Hidden Credential]" connectionString="DefaultEndpointsProtocol=http|https;AccountName=NAME;AccountKey=KEY" />, or
2. Set the environment variable named '[Hidden Credential]', or
3. Set corresponding property of JobHostConfiguration.
I'm not sure where to find and edit the .config file or add an environment variable. The connection string is already added to the function.json
file as seen below.
Also, I don't know whether just context.bindings.outputBlob = req.body;
is enough to create a blob in the storage container with content-type': 'application/octet-stream'
.
index.js:
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.bindings.outputBlob = req.body;
context.res = {
// status: 200, /* Defaults to 200 */
body: "Uploaded "
};
context.done();
};
function.json
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"route": "FileUploadNode/{filename}",
"methods": [
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "blob",
"name": "outputBlob",
"path": "CONTAINER-NAME/{filename}",
"connection": "SOME CONNECTION STRING",
"direction": "out"
}
],
"disabled": false
}