Azure Functions - 值不能为空.(参数“连接字符串")

2022-01-17 00:00:00 azure azure-functions javascript

我试图设置简单的 Azure 函数来读取 XML 流并将其同步回数据库.我的计划是使用时间触发器每天执行一次函数.

I was trying to setup simple Azure Function to read a XML stream and sync it back to the database. My plan was to use a Time Trigger to execute the function once per day.

但是,事情看起来不太好.即使我不使用数据库,我也会收到以下错误:

Howerver, things are not looking great. I'm getting the following error, even if I don't use a database:

[Error] Executed 'Functions.<func-name>' (Failed, Id=<func-id>, Duration=1ms)Value cannot be null. (Parameter 'connectionString')

我目前正在尝试执行以下功能:

I'm currently trying to execute the following function:

module.exports = async function(context, req) {
    context.res = {
        body: "Success!"
    };
};

同样的结果.我无法运行它.

Same result. I can't run it.

我在配置中添加了一个连接字符串 ->连接字符串(根据消息,我以为我错过了).

I've added a Connection String to the Configuration -> Connection Strings (I thought that I've missed that, based on the message).

我的 functions.json 文件如下所示:

My functions.json file looks like:

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 0 * * * *"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

我也尝试过运行 C# 函数 - 结果相同.

I've also tried running a C# function - same result.

那么,我错过了什么?

推荐答案

从 Microsoft 到最好的日志.

缺少 AzureWebJobsStorage 应用设置.

解决方案:

  1. 创建存储帐户(或使用现有帐户)
  2. 转到 Function App 的配置
  3. 将带有连接字符串的 AzureWebJobsStorage 添加到您的存储帐户(可在存储帐户概述 -> 访问密钥中找到)

相关文章