3

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).

My functions.json file looks like:

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

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

So, what have I missed?

Liliyan Krumov
  • 171
  • 1
  • 1
  • 8

3 Answers3

11

Logging from Microsoft to it's finest.

AzureWebJobsStorage App Setting was missing.

Solution:

  1. Create Storage account (or use existing one)
  2. Go to your Function App's Configuration
  3. Add AzureWebJobsStorage with a connection string to your Storage account (can be found at Storage Account Overview -> Access Keys)
Liliyan Krumov
  • 171
  • 1
  • 1
  • 8
2

In my case the error was Microsoft.Extensions.Configuration.AzureAppConfiguration value cannot be null: parameter (connectionString)

This happened because I has installed Microsoft.Extensions.Configuration.AzureAppConfiguration in my Function to DI the configuration into my main function. The Startup.cs line string cs = Environment.GetEnvironmentVariable("MyDifferentConnectionString"); was not able to find an environment variable for MyDifferentConnectionString, so this needed to be added to the Function config.

  1. Go to App Configuration (or create one)
  2. Access Keys (under Settings)
  3. Copy Connection String
  4. Go to your Function
  5. Configuration (under Settings)
  6. Add a new Application Settings with the name of your environment variable and paste the value
  7. Save and restart your Function
Red
  • 3,030
  • 3
  • 22
  • 39
  • I confirmed this solution solves the problem of connecting the Azure App Configuration service with Azure Functions. – Teerasej Jan 02 '23 at 06:02
  • I'll echo that this solved my problem. I had originally put the connection string in the "Connection Strings" section, but that's not where `GetEnvironmentalVariable` looks. – Adam Schumph Apr 12 '23 at 03:49
1

this is deployment issue, I just copied settings from appsettings.json /localsettings.json files into configuration section.

Muni Chittem
  • 988
  • 9
  • 17