无法解析名为“存储”的 Azure 存储连接 - Azure 持久函数

Rah*_*hul 2 json azure azure-durable-functions

我的项目

\n

包.json

\n
{\n  "name": "azure-functions",\n  "version": "1.0.0",\n  "description": "",\n  "scripts": {\n    "start": "func start",\n    "test": "echo \\"No tests yet...\\""\n  },\n  "dependencies": {\n    "durable-functions": "^2.0.2"\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

主机.json

\n
{\n  "version": "2.0",\n  "logging": {\n    "applicationInsights": {\n      "samplingSettings": {\n        "isEnabled": true,\n        "excludedTypes": "Request"\n      }\n    }\n  },\n  "extensionBundle": {\n    "id": "Microsoft.Azure.Functions.ExtensionBundle",\n    "version": "[3.*, 4.0.0)"\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

DurableFunctionsHttpStart/function.json

\n
{\n  "bindings": [\n    {\n      "authLevel": "anonymous",\n      "name": "req",\n      "type": "httpTrigger",\n      "direction": "in",\n      "route": "orchestrators/{functionName}",\n      "methods": [\n        "post",\n        "get"\n      ]\n    },\n    {\n      "name": "$return",\n      "type": "http",\n      "direction": "out"\n    },\n    {\n      "name": "starter",\n      "type": "orchestrationClient",\n      "direction": "in"\n    }\n  ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n

DurableFunctionsHttpStart/index.js

\n
const df = require("durable-functions");\n\nmodule.exports = async function (context, req) {\n    const client = df.getClient(context);\n    const instanceId = await client.startNew(req.params.functionName, undefined, req.body);\n\n    context.log(`Started orchestration with ID = \'${instanceId}\'.`);\n\n    return client.createCheckStatusResponse(context.bindingData.req, instanceId);\n};\n
Run Code Online (Sandbox Code Playgroud)\n

你好/function.json

\n
{\n  "bindings": [\n    {\n      "name": "name",\n      "type": "activityTrigger",\n      "direction": "in"\n    }\n  ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n

你好/index.js

\n
/*\n * This function is not intended to be invoked directly. Instead it will be\n * triggered by an orchestrator function.\n * \n * Before running this sample, please:\n * - create a Durable orchestration function\n * - create a Durable HTTP starter function\n * - run \'npm install durable-functions\' from the wwwroot folder of your\n *   function app in Kudu\n */\n\nmodule.exports = async function (context) {\n    return `Hello ${context.bindings.name}!`;\n};\n
Run Code Online (Sandbox Code Playgroud)\n

HelloOrchestrator/function.json

\n
{\n  "bindings": [\n    {\n      "name": "context",\n      "type": "orchestrationTrigger",\n      "direction": "in"\n    }\n  ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n

HelloOrchestrator/index.js

\n
/*\n * This function is not intended to be invoked directly. Instead it will be\n * triggered by an HTTP starter function.\n * \n * Before running this sample, please:\n * - create a Durable activity function (default name is "Hello")\n * - create a Durable HTTP starter function\n * - run \'npm install durable-functions\' from the wwwroot folder of your \n *    function app in Kudu\n */\n\nconst df = require("durable-functions");\n\nmodule.exports = df.orchestrator(function* (context) {\n    const outputs = [];\n\n    // Replace "Hello" with the name of your Durable Activity Function.\n    outputs.push(yield context.df.callActivity("Hello", "Tokyo"));\n    outputs.push(yield context.df.callActivity("Hello", "Seattle"));\n    outputs.push(yield context.df.callActivity("Hello", "London"));\n\n    // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]\n    return outputs;\n});\n
Run Code Online (Sandbox Code Playgroud)\n

运行时npm start在页面的根目录上

\n
Azure Functions Core Tools\nCore Tools Version:       4.0.4736 Commit hash: N/A  (64-bit)\nFunction Runtime Version: 4.8.1.18957\n\n[2022-09-05T11:52:51.483Z] A host error has occurred during startup operation \'5dd1dd91-e64a-4866-......\'.\n[2022-09-05T11:52:51.483Z] Microsoft.Azure.WebJobs.Extensions.DurableTask: Unable to resolve the Azure Storage connection named \'Storage\'.\nValue cannot be null. (Parameter \'provider\')\n
Run Code Online (Sandbox Code Playgroud)\n

可能是什么原因,我按照这个教程https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode

\n

我没有\xe2\x80\x99t收到任何提示选择天蓝色帐户,如此处所述https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode#test-the-局部功能

\n

Mo *_*emi 5

该异常表明运行时无法找到 的值AzureWebJobsStorage。您的项目中应该有一个local.settings.json如下所示的文件:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=....",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
Run Code Online (Sandbox Code Playgroud)

的值AzureWebJobsStorage应设置为 Azure 函数运行时所需的存储连接字符串。

请参阅:Azure Functions 的应用程序设置参考