我的项目
package.json
{
"name": "azure-functions",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "func start",
"test": "echo \"No tests yet...\""
},
"dependencies": {
"durable-functions": "^2.0.2"
}
}
字符串
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
}
}
型
DurableFunctionsHttpStart/function.json
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "orchestrators/{functionName}",
"methods": [
"post",
"get"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "starter",
"type": "orchestrationClient",
"direction": "in"
}
]
}
型
DurableFunctionsHttpStart/index.js
const df = require("durable-functions");
module.exports = async function (context, req) {
const client = df.getClient(context);
const instanceId = await client.startNew(req.params.functionName, undefined, req.body);
context.log(`Started orchestration with ID = '${instanceId}'.`);
return client.createCheckStatusResponse(context.bindingData.req, instanceId);
};
型
Hello/function.json
{
"bindings": [
{
"name": "name",
"type": "activityTrigger",
"direction": "in"
}
]
}
型
Hello/index.js
/*
* This function is not intended to be invoked directly. Instead it will be
* triggered by an orchestrator function.
*
* Before running this sample, please:
* - create a Durable orchestration function
* - create a Durable HTTP starter function
* - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/
module.exports = async function (context) {
return `Hello ${context.bindings.name}!`;
};
型
HelloOrchestator/function.json
{
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
]
}
型
HelloOrchestrator/index.js
/*
* This function is not intended to be invoked directly. Instead it will be
* triggered by an HTTP starter function.
*
* Before running this sample, please:
* - create a Durable activity function (default name is "Hello")
* - create a Durable HTTP starter function
* - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/
const df = require("durable-functions");
module.exports = df.orchestrator(function* (context) {
const outputs = [];
// Replace "Hello" with the name of your Durable Activity Function.
outputs.push(yield context.df.callActivity("Hello", "Tokyo"));
outputs.push(yield context.df.callActivity("Hello", "Seattle"));
outputs.push(yield context.df.callActivity("Hello", "London"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
});
型
在页面的根目录上运行npm start
时,我得到了以下错误。
Azure Functions Core Tools
Core Tools Version: 4.0.4736 Commit hash: N/A (64-bit)
Function Runtime Version: 4.8.1.18957
[2022-09-05T11:52:51.483Z] A host error has occurred during startup operation '5dd1dd91-e64a-4866-......'.
[2022-09-05T11:52:51.483Z] Microsoft.Azure.WebJobs.Extensions.DurableTask: Unable to resolve the Azure Storage connection named 'Storage'.
Value cannot be null. (Parameter 'provider')
型
原因可能是什么,我遵循了这个教程https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode
我https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode#test-the-function-locally
2条答案
按热度按时间uemypmqf1#
该异常表明运行时找不到
AzureWebJobsStorage
的值。您的项目中应该有一个local.settings.json
文件,看起来应该如下所示:字符串
应将
AzureWebJobsStorage
的值设置为Azure函数运行时所需的存储连接字符串。请参阅:Azure函数的应用程序设置参考
zbdgwd5y2#
我在另一个场景中得到了完全相同的错误
在我的例子中,它与这里提到的任何事情都完全无关。我在local.settings.json中有一个嵌套的配置元素,如下所示:
字符串
结果函数主机不喜欢这样,一旦我扁平化配置结构,错误就消失了。
型