耐用功能缺少连接字符串异常

时间:2018-10-15 19:13:46

标签: azure azure-functions azure-durable-functions

我有一个带有耐用功能(以及一些非耐用功能)的Function App,并且我收到一个InvalidOperationException,内容为:Unable to find an Azure Storage connection string to use for this binding.

这是堆栈跟踪:

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)

它似乎是持久功能,抱怨缺少连接字符串。但是,我确实在我的AzureWebJobsDashboard应用程序设置中填充了连接字符串,所以我不确定为什么会失败。

3 个答案:

答案 0 :(得分:0)

(此问题显示为没有答案,所以我接受Ling的建议并在此处将其变成一个正确的答案)

除了AzureWebJobsDashboard应用程序设置之外,您还需要在AzureWebJobsStorage应用程序设置中指定Azure存储连接字符串。包括持久功能在内的各种Azure功能功能都需要后一个应用程序设置。两个应用程序设置具有相同的连接字符串是可以的。

答案 1 :(得分:0)

此错误是由错误的网址引起的。 如果仿真器已停止,则返回: “由于目标计算机主动拒绝连接,因此无法建立连接” 请参阅:Create your first durable function in C#

解决方法:

1-确保Azure存储模拟器正在运行或重新启动

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:确保URL正确。输出包含几个网址,请确保为 statusQueryGetUri (这是最可能的原因)

{"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=="}

工作配置文件:

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

答案 2 :(得分:0)

正如其他答案所说,由于缺少 AzureWebJobsStorage 连接字符串,我收到了异常。但是,连接字符串存在于 appsettings.Development.json 文件中...

为了让 Durable Function 项目在本地启动,连接字符串需要位于 local.settings.json 文件中。