title: Azure Function Converting v1 to v2 DotNetStandard 'AzureWebJobsServiceBus' is missing or empty
body: <p>Sorry for the long post I just wanted to provide all the information I could and address questions before they come up.</p>
  
  <p>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. <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#trigger---configuration" rel="nofollow noreferrer">According to the documentation it should default</a> to the AzureWebJobsServiceBus value in the local.settings.json file and the ApplicationSettings on Azure.</p>
  
  <blockquote>
    <p>A host error has occurred</p>
    
    <p>Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsServiceBus' is missing or empty.</p>
  </blockquote>
  
  <p>I get a runtime exception immediately after that posts in the Console in JobHost.cs that "The host has not yet started."</p>
  
  <blockquote>
    <p>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)</p>
  </blockquote>
  
  <p>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())"</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>local.settings.json (among many values):</p>
  
  <pre><code>  ...,
    "Values": {
      "FUNCTIONS_WORKER_RUNTIME": "dotnet",
      "AzureWebJobsServiceBus": "Endpoint=sb://[my_name].servicebus.windows.net/;SharedAccessKeyName=LocalManage;SharedAccessKey=[my_key]",
      ...
  </code></pre>
  
  <p>My csproj file reads:</p>
  
  <pre><code>  &lt;TargetFramework&gt;netstandard2.0&lt;/TargetFramework&gt;
    &lt;AzureFunctionsVersion&gt;v2&lt;/AzureFunctionsVersion&gt;
    &lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;
  </code></pre>
  
  <p>I am working in Visual Studio 2017 Version 15.9.9</p>
  
  <p>Azure Functions and Web Job Tools is 15.10.2046.0</p>
  
  <p>Edit:</p>
  
  <p>Doesn't seem limited to converting from v1 to v2</p>
  
  <p><strong>Recreation Steps</strong></p>
  
  <ol>
  <li>Using Visual Studio 2017 go to File -> New -> Project -> Azure Functions -> Ok</li>
  <li>Choose Azure Functions v2 (.NET Core)</li>
  <li>Choose Empty</li>
  <li>Right click Project -> Add ->New Azure Function</li>
  <li>Select Service Bus Queue Trigger</li>
  <li>Go to local.settings.json and add a ServiceBusConnectionString</li>
  <li>Start Debugging and you'll get the exception above.</li>
  </ol>