Sorry for the long post I just wanted to provide all the information I could and address questions before they come up.
Working on converting an Azure Function v1 .NET Framework 4.6.1 to a DotNetStandard 2.0 for the Dependency Injection extension. At runtime I get an exception in the Console that reads an error that the connection string is missing but it's in the local.settings.json as it was in v1. According to the documentation it should default to the AzureWebJobsServiceBus value in the local.settings.json file and the ApplicationSettings on Azure.
A host error has occurred
Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsServiceBus' is missing or empty.
I get a runtime exception immediately after that posts in the Console in JobHost.cs that "The host has not yet started."
at Microsoft.Azure.WebJobs.JobHost.StopAsync() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 121 at Microsoft.Azure.WebJobs.Hosting.JobHostService.StopAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\JobHostService.cs:line 32 at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken cancellationToken)
Continuing through that exception gives me the next one "Container is disposed and should not be used: Container is disposed. You may include Dispose stack-trace into the message via: container.With(rules => rules.WithCaptureContainerDisposeStackTrace())"
at DryIoc.Throw.It(Int32 error, Object arg0, Object arg1, Object arg2, Object arg3) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:line 8991 at DryIoc.Container.ThrowIfContainerDisposed() in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:line 411 at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType, IfUnresolved ifUnresolved) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:line 200 at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:line 195 at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.GetService(Type serviceType, IfUnresolved ifUnresolved) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs:line 101 at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.GetRequiredService(Type serviceType) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs:line 84 at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Azure.Functions.Cli.Actions.HostActions.StartHostAction.RunAsync() in C:\azure-functions-cli\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 241
local.settings.json (among many values):
...,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureWebJobsServiceBus": "Endpoint=sb://[my_name].servicebus.windows.net/;SharedAccessKeyName=LocalManage;SharedAccessKey=[my_key]",
...
My csproj file reads:
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
I am working in Visual Studio 2017 Version 15.9.9
Azure Functions and Web Job Tools is 15.10.2046.0
Edit:
Doesn't seem limited to converting from v1 to v2
Recreation Steps
- Using Visual Studio 2017 go to File -> New -> Project -> Azure Functions -> Ok
- Choose Azure Functions v2 (.NET Core)
- Choose Empty
- Right click Project -> Add ->New Azure Function
- Select Service Bus Queue Trigger
- Go to local.settings.json and add a ServiceBusConnectionString
- Start Debugging and you'll get the exception above.
Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsServiceBus' is missing or empty.
when it's right there in my settings. Are you behind a proxy or firewall? I've found that I cannot run service bus functions locally due to our corporate firewall, and there's no option to fallback on HTTP. – Joe