gpt4 book ai didi

json - 无法解析名为 'Storage' 的 Azure 存储连接 - Azure 持久函数

转载 作者:行者123 更新时间:2023-12-02 23:14:41 25 4
gpt4 key购买 nike

我的项目

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"
}
}

主机.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);
};

你好/function.json

{
"bindings": [
{
"name": "name",
"type": "activityTrigger",
"direction": "in"
}
]
}

你好/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}!`;
};

HelloOrchestrator/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

我没有收到任何提示选择此处提到的 Azure 帐户 https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode#test-the-function-locally

最佳答案

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

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=....",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}

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

参见:App settings reference for Azure Functions

关于json - 无法解析名为 'Storage' 的 Azure 存储连接 - Azure 持久函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73610382/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com