我试图在JS中通过简单的Azure函数HTTPTrigger上传一个文件,它给了我以下错误:
[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.
我不确定在哪里可以找到和编辑.config文件,也不知道在哪里添加环境变量。连接字符串已经添加到function.json
文件中,如下所示。
此外,我不知道使用content-type': 'application/octet-stream'
在存储容器中创建blob是否只需要context.bindings.outputBlob = req.body;
。
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
}
https://stackoverflow.com/questions/50573988
复制相似问题