azure-functions-host: Container is disposed and should not be used: Container is disposed.

I just found the following exception in the log for an Azure Function:

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())

stacktrace_1573671261

It’s the first and only time I see this exception, so don’t know how critical it is. But still, think you may want to know about it.

I’m using the following versions:

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />

The function is triggered by events on an Azure Service Bus topic. DI is configured using a Startup.cs file:

[assembly: FunctionsStartup(typeof(Blabla.Startup))]

namespace Blabla
{
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var config = new ConfigurationBuilder()
                .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .Build();
            ...
            builder.Services.AddSingleton(config);
       }
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 14
  • Comments: 73 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Any update on this issue. We are also facing the same problem in the PROD environment.

@ChrisHimsworth I am running into the same issue. I have spoke with MS and it has to do with the AZF either switching instances or shutting down in the middle of your execution. The scale controller determines if this should be done or not. Only MS can see the logs of your processID switching HostInstanceIds so you will need their help to confirm you’re hitting the same reason why.

I haven’t tried it yet but the quick recommendation/solution is to switch to the Premium Plan because MS recently introduced a “drain mode” on it. Drain mode stops sending requests to the AZF and lets it’s current executions complete/timeout. This would allow a true graceful shut down of the AZF. Ideally this would have been there all along and on Consumption plan, but it is what it is. It’s hard to tell the health of your application because this error actually spawns other types of exceptions around IOC.

A little off topic but a few things that led up to this that I had to fix that might be of some value.

  1. Support cancellation tokens. This will reduce the number of “User Errors” on the Service Bus (using a [ServiceBusTrigger]). This is MS attempting to tell you that the current execution is going to be cancelled and the message will be replayed for you. This was a easy win by doing

[FunctionName(“MyFunctionApp”)] public async Task MyFunctionApp([ServiceBusTrigger(“MyTopic”, sub, Connection = busConn)]Message message, ILogger log, CancellationToken token) { if (!token.IsCancellationRequested) { // await do work } }

  1. The AZF start up time for my setup is about a min (cold start). The default lock duration of a ServiceBus Topic Sub is 1 min. Boost the Lock Duration to be more than your startup time to greatly reduce the “The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue, or was received by a different receiver instance.” exception.
  2. Ensure your configuration in FunctionStartup is setup in the correct area. This doesn’t really have to do with the ticket but I wanted to pointed it out because you will need it for your configuration to honor the host.json file. I did not know about this.

[assembly: FunctionsStartup(typeof(MyNameSpace.Startup))] namespace MyNameSpace { public class Startup : FunctionsStartup { public override void Configure(IFunctionsHostBuilder builder) { //var config = builder.GetContext().Configuration; <===get access to the config so you can use it for your ioc //setup IOC } public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder) { //setup configuration and KV //https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection#customizing-configuration-sources } } }

  1. When I throw an exception in my code I attach the MessageBusID to so I can correlate DLQs to an exception. The DLQs that I am seeing do NOT have my MessageBusID attached them. This leads me to believe that during these shutdowns if the message fails 10 times whether on shutdowns or cold starts it with exceptions like the DryIoc/container disposed of one. I ended up resubmitted the DLQ messages and the code worked just fine. If MS throws a message in the DLQ it says “Retried 10 times” but it doesn’t say what caused retried or correlated the exception with the messageID. This would allow me to confirm it’s MS code pushing it into the DLQ.

Like I mentioned the above list is what I did to get to widdle down exception to just the DryIOC/container disposed of exception. I am not trying to confuse anyone but wanted to show it.

I’ll let you know if I find anything else

Would be nice with a confirmation about this issue from someone on the Functions team.

Just an update – I’ve started to investigate this more deeply and am working on a repro to see what we can do here to either prevent this or, at least, improve the exception so we have a better understanding of the cause.

Ultimately it’s because the host is already disposed (it’s in the process of shutting down) and something is attempting to create a new scope. Sometimes this is a race condition in a trigger – sometimes it’s in function code – but just judging from the current callstacks we can’t quite determine the culprits.

Is there any update on this? We have tried upgrading to version 4.2.2 of Microsoft.Azure.WebJobs.Extensions.ServiceBus, but we still get issues. Every time it happens we get two exceptions logged. Both contain the same error message:

The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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()) 

1st exception:

Microsoft.Azure.WebJobs.Script.HostDisposedException:
   at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync (Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener+<ProcessMessageAsync>d__33.MoveNext (Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.ServiceBus.MessageReceivePump+<MessageDispatchTask>d__14.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
Inner exception DryIoc.ContainerException handled at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync:
   at DryIoc.Throw.It (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 9000)
   at DryIoc.Container.ThrowIfContainerDisposed (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 412)
   at DryIoc.Container.WithCurrentScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 438)
   at DryIoc.ResolverContext.OpenScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 2709)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 51)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 43)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 106)

2nd exception:

Microsoft.Azure.WebJobs.Script.HostDisposedException:
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 110)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 52)
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 32)
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1+<>c__DisplayClass1_1.<.ctor>b__0 (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 20)
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 26)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 44)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+ParameterHelper.Initialize (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 758)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsync>d__15.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 90)
Inner exception DryIoc.ContainerException handled at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope:
   at DryIoc.Throw.It (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 9000)
   at DryIoc.Container.ThrowIfContainerDisposed (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 412)
   at DryIoc.Container.WithCurrentScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 438)
   at DryIoc.ResolverContext.OpenScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 2709)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 51)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 43)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 106)

I too am getting this issue with ServiceBusTrigger.

I only get this when using Microsoft.Azure.WebJobs.Extensions.ServiceBus 4.2.1 (or 4.2.0). The issue is not present when running with 4.1.0, 4.1.1 or 4.1.2. I note 4.2.0 contained Support for message draining before the Functions host shuts down.

My package references are:

    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.2" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.12" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />

These errors always coincide with JobHost restarts. Here are some Kudo function host log extracts that hopefully provided more context for the exceptions:

2021-03-03T11:33:33.188 [Debug] Hosting stopping
2021-03-03T11:33:33.189 [Debug] Stopping file watchers.
2021-03-03T11:33:33.236 [Information] Change analysis service stopped before analysis completion. Waiting for cancellation
2021-03-03T11:33:33.252 [Debug] Waiting for RpcFunctionInvocationDispatcher to shutdown
2021-03-03T11:33:33.260 [Debug] Draining invocations from language worker channel completed. Shutting down 'RpcFunctionInvocationDispatcher'
2021-03-03T11:33:33.271 [Information] Stopping JobHost
2021-03-03T11:33:33.281 [Information] Stopping the listener 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener' for function 'vs-bus-bx'
2021-03-03T11:33:34.392 [Information] Executing 'vs-bus-bx' (Reason='(null)', Id=8aaaa07a-1de1-4b07-b14f-0b387baaa031)
2021-03-03T11:33:34.392 [Information] Trigger Details: MessageId: cea6a9ff-7714-497f-ba56-dbeed0ee2b2a.1887b206-5611-4e75-9690-791c9bb60698.2021-03-03T11:33:34.3270000Z.286D67E1, SequenceNumber: 38280596832993611, DeliveryCount: 1, EnqueuedTimeUtc: 2021-03-03T11:33:34.3730000Z, LockedUntilUtc: 2021-03-03T11:34:04.3730000Z, SessionId: (null)
2021-03-03T11:33:34.556 [Information] Executed 'vs-bus-bx' (Succeeded, Id=8aaaa07a-1de1-4b07-b14f-0b387baaa031, Duration=166ms)
2021-03-03T11:33:38.603 [Information] Executing 'vs-bus-bx' (Reason='(null)', Id=87af4122-03bb-4f69-a105-fd972f57ff88)
2021-03-03T11:33:38.603 [Information] Trigger Details: MessageId: cea6a9ff-7714-497f-ba56-dbeed0ee2b2a.1887a045-30db-44bc-8357-20eba84671ac.2021-03-03T11:33:38.4050000Z.FD0296E, SequenceNumber: 56294995342475157, DeliveryCount: 1, EnqueuedTimeUtc: 2021-03-03T11:33:38.5420000Z, LockedUntilUtc: 2021-03-03T11:34:08.5580000Z, SessionId: (null)
2021-03-03T11:33:38.840 [Information] Executed 'vs-bus-bx' (Succeeded, Id=87af4122-03bb-4f69-a105-fd972f57ff88, Duration=239ms)
2021-03-03T11:33:40.026 [Error] Executed 'vs-bus-bx' (Failed, Id=1638f25f-6790-4f7c-9ba8-094b4251564d, Duration=93ms)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 110
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.cs : 50
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 32
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.<>c__DisplayClass1_1.<.ctor>b__0(IFunctionInstanceEx i) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 20
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 26
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs : 44
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 762
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 90
2021-03-03T11:33:40.034 [Error] Executed 'vs-bus-bx' (Failed, Id=9cd8b6ab-2416-4cb8-83d8-c5f79eefa4e1, Duration=1ms)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 110
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.cs : 50
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 32
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.<>c__DisplayClass1_1.<.ctor>b__0(IFunctionInstanceEx i) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 20
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 26
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs : 44
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 762
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 90
2021-03-03T11:33:40.107 [Error] Message processing error (Action=UserCallback, ClientId=MessageReceiver1from-devices/Subscriptions/bx, EntityPath=from-devices/Subscriptions/bx, Endpoint=vs-prod-bus.servicebus.windows.net)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync(Message message,FunctionResult result,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener.ProcessMessageAsync(Message message,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.ServiceBus.MessageReceivePump.MessageDispatchTask(Message message)
2021-03-03T11:33:40.172 [Error] Message processing error (Action=UserCallback, ClientId=MessageReceiver1from-devices/Subscriptions/bx, EntityPath=from-devices/Subscriptions/bx, Endpoint=vs-prod-bus.servicebus.windows.net)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync(Message message,FunctionResult result,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener.ProcessMessageAsync(Message message,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.ServiceBus.MessageReceivePump.MessageDispatchTask(Message message)
2021-03-03T11:33:40.200 [Error] Executed 'vs-bus-bx' (Failed, Id=3bd2c414-48c7-4f75-8b6f-adbf8fe29dfe, Duration=1ms)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 110
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.cs : 50
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 32
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.<>c__DisplayClass1_1.<.ctor>b__0(IFunctionInstanceEx i) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 20
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 26
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs : 44
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 762
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 90
2021-03-03T11:33:40.244 [Error] Message processing error (Action=UserCallback, ClientId=MessageReceiver1from-devices/Subscriptions/bx, EntityPath=from-devices/Subscriptions/bx, Endpoint=vs-prod-bus.servicebus.windows.net)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync(Message message,FunctionResult result,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener.ProcessMessageAsync(Message message,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.ServiceBus.MessageReceivePump.MessageDispatchTask(Message message)
2021-03-03T11:33:40.266 [Error] Executed 'vs-bus-bx' (Failed, Id=d6506c60-7d62-4134-879a-fa0c35ce824a, Duration=2ms)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 110
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.cs : 50
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 32
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.<>c__DisplayClass1_1.<.ctor>b__0(IFunctionInstanceEx i) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 20
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 26
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs : 44
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 762
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 90
2021-03-03T11:33:40.308 [Error] Message processing error (Action=UserCallback, ClientId=MessageReceiver1from-devices/Subscriptions/bx, EntityPath=from-devices/Subscriptions/bx, Endpoint=vs-prod-bus.servicebus.windows.net)
Microsoft.Azure.WebJobs.Script.HostDisposedException : The host is disposed and cannot be used. Disposed object: 'Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver'; Found IListener in stack trace: 'Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener, Microsoft.Azure.WebJobs.ServiceBus, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> DryIoc.ContainerException : 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) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 9000
   at DryIoc.Container.ThrowIfContainerDisposed() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 412
   at DryIoc.Container.WithCurrentScope(IScope scope,Boolean preferInterpretaion) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 438
   at DryIoc.ResolverContext.OpenScope(IResolverContext r,Object name,Boolean trackInParent,Boolean preferInterpretation) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 2709
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.WebHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\WebHostServiceProvider.cs : 51
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope(IServiceScopeFactory rootScopeFactory) at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs : 43
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope() at D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs : 106
   End of inner exception
   at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync(Message message,FunctionResult result,CancellationToken cancellationToken)
   at async Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener.ProcessMessageAsync(Message message,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.ServiceBus.MessageReceivePump.MessageDispatchTask(Message message)
2021-03-03T11:34:02.448 [Information] Initializing Warmup Extension.
2021-03-03T11:34:02.509 [Information] Initializing Host. OperationId: '658085a1-55a4-47ec-a00f-f492ee21fd0d'.
2021-03-03T11:34:02.524 [Information] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=658085a1-55a4-47ec-a00f-f492ee21fd0d
2021-03-03T11:34:02.554 [Debug] Hosting starting

I don’t profess to understand all this but it seems to me that the DI Container has been disposed before all messages have drained?

If it’s helpful here are the reported function startup options:

2021-03-03T11:34:02.573 [Information] FunctionResultAggregatorOptions
{
  "BatchSize": 1000,
  "FlushTimeout": "00:00:30",
  "IsEnabled": true
}
2021-03-03T11:34:02.573 [Information] SingletonOptions
{
  "LockPeriod": "00:00:15",
  "ListenerLockPeriod": "00:01:00",
  "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
  "LockAcquisitionPollingInterval": "00:00:05",
  "ListenerLockRecoveryPollingInterval": "00:01:00"
}
2021-03-03T11:34:02.573 [Information] ServiceBusOptions
{
  "PrefetchCount": 0,
  "MessageHandlerOptions": {
    "AutoComplete": true,
    "MaxAutoRenewDuration": "00:05:00",
    "MaxConcurrentCalls": 16
  },
  "SessionHandlerOptions": {
    "AutoComplete": true,
    "MaxAutoRenewDuration": "00:05:00",
    "MaxConcurrentSessions": 2000,
    "MessageWaitTimeout": "00:01:00"
  },
  "BatchOptions": {
    "MaxMessageCount": 1000,
    "OperationTimeout": "00:01:00",
    "AutoComplete": true
  }
}

Would be grateful for any update on this.

@brettsam - Is this being looked into? A lot of people are experiencing the issue outside of the original Azure Durable Functions sphere and example raised (see above) and the issue is causing data to be dropped?

@brettsam has there been any more movement on this issue? We are seeing this exception a few times a day, resulting deadletters on our queues.

Just as info, I experienced this with the Azure ServiceBus bindings and not EventHub 👍

Still seeing these today. Using .Net 5 isolated.

image

Microsoft.Azure.WebJobs.Script.HostDisposedException:
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs:110)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInstance.get_InstanceServices (Microsoft.Azure.WebJobs.Host, Version=3.0.29.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInstance.cs:52)
   at Microsoft.Azure.WebJobs.Host.Bindings.FunctionBindingContext..ctor (Microsoft.Azure.WebJobs.Host, Version=3.0.29.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\FunctionBindingContext.cs:66)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__20.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.29.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:252)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsync>d__15.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.29.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:94)
Inner exception DryIoc.ContainerException handled at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope:
   at DryIoc.Throw.It (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:9000)
   at DryIoc.Container.ThrowIfContainerDisposed (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:412)
   at DryIoc.Container.WithCurrentScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:438)
   at DryIoc.ResolverContext.OpenScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs:2709)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedResolver.CreateChildScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\ScopedResolver.cs:43)
   at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostServiceProvider.CreateScope (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\DependencyInjection\JobHostServiceProvider.cs:106)

It seems as if the functions team have abandoned GitHub issues recently there are a few issues that have been open for a long time without any input or progress being updated. It’s very frustrating from the communities perspective as we don’t know if you’re working on something, if it’s blocked by something else, if you’ve forgotten about it or anything 😕

Love the platform and the direction it’s going I just think you’d be better placed if you kept the community up to date with what’s going on 😃

Our workaround was to make all our functions idempotent and increased the maxDeliveryCount on all our queues to allow multiple retries. This caters for the the DryIoc exception that occurs before the trigger has a chance to execute.

As a side note we also added CustomMessagingProvider to handle in-trigger exceptions. See here for an example - https://github.com/Azure/azure-functions-servicebus-extension/blob/dev/test/Microsoft.Azure.WebJobs.Extensions.ServiceBus.Tests/ServiceBusEndToEndTests.cs#L933

We also ended up adding exponential retries with something similar to this implementation https://github.com/Azure/azure-functions-host/issues/2192#issuecomment-465891229

Actually the “job queue” here is a db table for holding jobs to be done. The message from the service bus just give me a GUID that referes to the item in the db table

I had this issue, but the it’s gone now, I think the issue you are facing are in fact not an error but a missunderstanding…

        public TaskQWorkerFunction(IJobQueueWorker taskQWorker, IJobQueueManagement management, ItemSerializer<string> serializer, IServiceScopeFactory scopeFactory)
        {
            this.taskQWorker = taskQWorker;
            this.serializer = serializer;
            this.scopeFactory = scopeFactory;
            this.management = management;
        }

The constructor of the class

               [FunctionName("IndexItemsFromServiceBus")]
        public async Task Run([ServiceBusTrigger("taskstodo")] string myQueueItem, string label, ILogger logger)
        {
            var msg = serializer.Deserialize<JobQueueItemCreated>(myQueueItem);
            TaskQ.Contracts.Models.JobToBeDone jobToBeDone;
            try
            {
                jobToBeDone = await management.GetJobById(msg.Guid);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Job with id {msg.Guid} not found");
                return;
            }


            using (var scope = scopeFactory.CreateScope()) //<-- this solves the issue.. :D
            {
                try
                {
                    await taskQWorker.HandleTask(jobToBeDone); // <- Use the scope to create you "worker service" here
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, $"{jobToBeDone} : {ex.Message}");
                    throw;
                }
            }
        }

this is what the body of my message handler looks like.

After doing this way the exception disappeared

Having trouble with this issue as well. Is there any progress being made?

@gorillapower same here. i never saw this issue until we recently upgraded to the latest service bus extension package so it sounds like a regression. i have an open ticket with MS but it’s not going anywhere at the moment.

@ChrisHimsworth what version of the trigger are you using? The extension has recently been updated to address issues with termination where it would attempt to use services or perform function invocations after a shutdown request, which would trigger service resolution outside or their lifetime scope.

Has there been any traction on this issue? I’m facing the same problem and was wondering if anyone has figured out the root cause.

A quick comment. Happy to hear that you resolved the issue by removing the Telemetry Client. I don’t have that installed, why the error is definitely still there. Could be another feature causing a similar problem, of course.

I’ve opened an issue and created a PR to fix this temporarily, until the EventHub team chooses what to do.

The PR basically doesn’t progress the checkpointer (thus retrying to process the failed event) when internal exceptions such as this occur. It works fine and we’re using it in production.

Issue: https://github.com/Azure/azure-functions-eventhubs-extension/issues/66 PR: https://github.com/xzuttz/azure-functions-eventhubs-extension/pull/1 MyGet package: https://www.myget.org/feed/xzuttz/package/nuget/Microsoft.Azure.WebJobs.Extensions.EventHubs

I have the same problem while using azure function service bus trigger. it’s not happening permanently. it happens once or twice a day and leads to deadlettering my messages.

It looks like 2.2.1 has some of the fixes surrounding this. https://github.com/Azure/azure-functions-durable-extension/releases/tag/v2.2.1 – specifically this item:

Fix orchestration/activity failures that occur during Functions host shutdowns (https://github.com/Azure/azure-functions-durable-extension/pull/1242)

Can you move to that and see if the problem persists?