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?

4 Answers 4

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)
Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

I confirmed this solution solves the problem of connecting the Azure App Configuration service with Azure Functions.
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.
2

If this is for local development using the local Azurite emulator then putting this into local.settings.json fixes it.

"AzureWebJobsStorage": "UseDevelopmentStorage=true"

More details here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-local#local-storage-emulator

1 Comment

This is the actual solution.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.