Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions - Value cannot be null. (Parameter 'connectionString')

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?

like image 391
Liliyan Krumov Avatar asked Jul 23 '26 09:07

Liliyan Krumov


2 Answers

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)
like image 200
Liliyan Krumov Avatar answered Jul 25 '26 00:07

Liliyan Krumov


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
like image 20
Red Avatar answered Jul 25 '26 01:07

Red