5

I have a Function App with a durable function (and some non-durable functions as well) and I'm getting an InvalidOperationException that says: Unable to find an Azure Storage connection string to use for this binding.

Here's the stacktrace:

System.InvalidOperationException:
  at Microsoft.Azure.WebJobs.Extensions.DurableTask.DurableTaskExtension.GetOrchestrationServiceSettings (Microsoft.Azure.WebJobs.Extensions.DurableTask, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null)
  at Microsoft.Azure.WebJobs.Extensions.DurableTask.DurableTaskExtension.Microsoft.Azure.WebJobs.Host.Config.IExtensionConfigProvider.Initialize (Microsoft.Azure.WebJobs.Extensions.DurableTask, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null)
  at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.InvokeExtensionConfigProviders (Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.CreateStaticServices (Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  at Microsoft.Azure.WebJobs.JobHost.InitializeServices (Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  at Microsoft.Azure.WebJobs.Script.Utility.CreateMetadataProvider (Microsoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Utility.csMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 362)
  at Microsoft.Azure.WebJobs.Script.ScriptHost.LoadBindingExtensions (Microsoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Host\ScriptHost.csMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 966)
  at Microsoft.Azure.WebJobs.Script.ScriptHost.Initialize (Microsoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Host\ScriptHost.csMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 299)
  at Microsoft.Azure.WebJobs.Script.ScriptHostManager.RunAndBlock (Microsoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Host\ScriptHostManager.csMicrosoft.Azure.WebJobs.Script, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 177)

It appears to be the durable function that's complaining about the missing connection string. However, I do have the connection string populated in my AzureWebJobsDashboard app setting, so I'm not sure why it's failing.

jlo-gmail
  • 4,453
  • 3
  • 37
  • 64
Joe Eng
  • 1,072
  • 2
  • 15
  • 30

5 Answers5

5

As other answers have said, I was getting the exception due to the missing AzureWebJobsStorage connection string. The connection string was, however, present in the appsettings.Development.json file...

In order to get the Durable Function project to start up locally, the connection string needed to be in the local.settings.json file.

John
  • 291
  • 3
  • 6
  • Yeah, same here: value was present in another config file but I wasn't using a local.settings.config on this project; added it and it's working again, thanks! – Rubens Farias Sep 26 '21 at 14:16
  • Thanks, John, adding local.settings.json resolved my issue. thanks – gouravm Nov 30 '22 at 06:08
2

(This question showed as not having an answer, so I'm taking Ling's suggestion and making it into a proper answer here)

In addition to the AzureWebJobsDashboard app setting, you also need to specify your Azure Storage connection string in the AzureWebJobsStorage app setting. The latter app setting is required by a variety of Azure Functions features, including Durable Functions. It's okay for the two app settings to have the same connection string.

Chris Gillum
  • 14,526
  • 5
  • 48
  • 61
2

I was also facing the same issue. Updated Nuget pacakges, adding extentions didn't work, but after John answer, I figured it out what I was missing.

Error message

It got resolved as I didn't have local.settings.json file so after adding it got resolved .

Attaching my local.setting.json which had the azureWebStotrage attribute.

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

I hope someone finds this useful.

gouravm
  • 301
  • 1
  • 12
1

This error is caused by an incorrect url. If the emulator is stopped, you get back: "No connection could be made because the target machine actively refused it" Refer to: Create your first durable function in C#

Resolutions:

1 - Ensure Azure Storage Emulator is working or restart it

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>AzureStorageEmulator.exe stop
Windows Azure Storage Emulator 5.10.0.0 command line tool
The storage emulator was successfully stopped.

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>AzureStorageEmulator.exe start
Windows Azure Storage Emulator 5.10.0.0 command line tool
The storage emulator was successfully started.

2: Ensure url is correct. The output contains several urls, make sure you take the one for statusQueryGetUri, (this is the most likely cause):

{"id":"57756e5133f047ed9213b3956c0268be",
"statusQueryGetUri":"http://localhost:7071/runtime/webhooks/durabletask/instances/57756e5133f047ed9213b3956c0268be?taskHub=TestHubName&connection=Storage&code=Ruk2CuiKU7yk9GM1qjalxynMwk2Bx2/KOpz78lxmPa4cNb2AtDZppw==",
"sendEventPostUri":"http://localhost:7071/runtime/webhooks/durabletask/instances/57756e5133f047ed9213b3956c0268be/raiseEvent/{eventName}?taskHub=TestHubName&connection=Storage&code=Ruk2CuiKU7yk9GM1qjalxynMwk2Bx2/KOpz78lxmPa4cNb2AtDZppw==",
"terminatePostUri":"http://localhost:7071/runtime/webhooks/durabletask/instances/57756e5133f047ed9213b3956c0268be/terminate?reason={text}&taskHub=TestHubName&connection=Storage&code=Ruk2CuiKU7yk9GM1qjalxynMwk2Bx2/KOpz78lxmPa4cNb2AtDZppw==",
"purgeHistoryDeleteUri":"http://localhost:7071/runtime/webhooks/durabletask/instances/57756e5133f047ed9213b3956c0268be?taskHub=TestHubName&connection=Storage&code=Ruk2CuiKU7yk9GM1qjalxynMwk2Bx2/KOpz78lxmPa4cNb2AtDZppw=="}

Working config file:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}
jlo-gmail
  • 4,453
  • 3
  • 37
  • 64
  • This did the trick for me. Had to add `"AzureWebJobsStorage": "UseDevelopmentStorage=true",` to my local.settings.json file. This will start the emulator. The setting appeared empty at first. – Perneel Apr 20 '21 at 07:41
1

I got this error after updating Microsoft.Azure.WebJobs from Nuget packages, then "AzureWebJobsStorage" will be an empty string like

{
"IsEncrypted": false,
"Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
}

}

Then go to your

local.settings.json

Then add this one

{
"IsEncrypted": false,
"Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
}

}

Hope it'll work.