Azure Functions Scoped 实例已被处置且不再可用
Azure Functions Scoped instances are disposed and no longer available
当函数应用程序在 运行-time 版本“2.0.12701.0" (FUNCTIONS_EXTENSION_VERSION = ~2 in App Settings)
上 运行ning 时,我收到以下错误。一旦我在应用程序设置中更改 FUNCTIONS_EXTENSION_VERSION to 2.0.12673.0
. 功能开始工作,无需任何代码更改或部署。
错误:
DryIoc.ContainerException : Scope disposed{no name, Parent=disposed{no
name, Parent=disposed{no name}}} is disposed and scoped instances are
disposed and no longer available. at DryIoc.Throw.It(Int32
error,Object arg0,Object arg1,Object arg2,Object arg3) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 8991 at DryIoc.Scope.TryGet(Object& item,Int32 id) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7881 at
DryIoc.Container.InstanceFactory.GetAndUnwrapOrDefault(IScope
scope,Int32 factoryId) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 1480 at
DryIoc.Container.InstanceFactory.GetInstanceFromScopeChainOrSingletons(IResolverContext
r) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 1466 at
DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type
serviceType,IfUnresolved ifUnresolved) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 224 at DryIoc.Container.DryIoc.IResolver.Resolve(Type
serviceType,IfUnresolved ifUnresolved) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 195 at DryIoc.Resolver.Resolve[TService](IResolver
resolver,IfUnresolved ifUnresolved) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 4742 at
DryIoc.Microsoft.DependencyInjection.DryIocAdapter.<>c__DisplayClass3_0.b__0(IResolverContext
r) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\DryIocAdapter.cs
: 156 at
DryIoc.Registrator.<>c__DisplayClass27_0.b__0(IResolverContext
r) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 4541 at lambda_method(Closure ,IResolverContext ) at
DryIoc.Factory.<>c__DisplayClass26_1.b__2() at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 6596 at DryIoc.Scope.TryGetOrAdd(ImMap1 items,Int32
id,CreateScopedValue createValue,Int32 disposalOrder) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7840 at DryIoc.Scope.GetOrAdd(Int32 id,CreateScopedValue
createValue,Int32 disposalOrder) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7825 at DryIoc.Factory.ApplyReuse(Expression serviceExpr,Request
request) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 6595 at DryIoc.Factory.GetExpressionOrDefault(Request request) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 6555 at DryIoc.Factory.GetDelegateOrDefault(Request request) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 6625 at DryIoc.DelegateFactory.GetDelegateOrDefault(Request
request) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7731 at DryIoc.Container.DryIoc.IResolver.Resolve(Type
serviceType,Object serviceKey,IfUnresolved ifUnresolved,Type
requiredServiceType,Request preResolveParent,Object[] args) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 290 at lambda_method(Closure ) at
DryIoc.Scope.TryGetOrAdd(ImMap
1 items,Int32 id,CreateScopedValue
createValue,Int32 disposalOrder) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7840 at DryIoc.Scope.GetOrAdd(Int32 id,CreateScopedValue
createValue,Int32 disposalOrder) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 7825 at lambda_method(Closure ,IResolverContext ) at
DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type
serviceType,IfUnresolved ifUnresolved) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 224 at DryIoc.Container.DryIoc.IResolver.Resolve(Type
serviceType,IfUnresolved ifUnresolved) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs
: 195 at
Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedServiceProvider.GetService(Type
serviceType) at
C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\ScopedServiceProvider.cs
: 25 at
Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider
sp,Type type,Type requiredBy,Boolean isDefaultParameterRequired) at
lambda_method(Closure ,IServiceProvider ,Object[] ) at
Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IServiceProvider
serviceProvider) at
C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs
: 37 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.ActivatorInstanceFactory1.<>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
: 846 at async
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsyncCore(IFunctionInstanceEx
functionInstance,CancellationToken cancellationToken) at
C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs
: 116
更改应用程序设置中的功能 运行-时间版本 (FUNCTIONS_EXTENSION_VERSION =2.0.12673.0) 从默认 运行-时间版本 2.0.12701.0 修复了问题。
这是我的 Function App Startup class,它注册了依赖项。
public class FunctionAppStartup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddJsonFile("secret.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
builder.Services.Configure<ConfigurationManager>(x => config.Bind(x));
builder.Services.AddSingleton<Contracts.IConfiguration>(resolver =>
resolver.GetRequiredService<IOptions<ConfigurationManager>>().Value);
builder.Services.AddScoped<IChannelAdapter, ChannelAdapter>();
builder.Services.AddScoped<ITableStorageManager, TableStorageManager>();
builder.Services.AddSingleton<IDatabaseContext, DatabaseContext>();
builder.Services.AddScoped<IJobRepository, JobRepository>();
}
}
期望我的函数应用程序在最新的 运行 版本上运行 运行,而不是我针对较小的 运行 版本。
从现在开始,您无法使用此运行时版本。
因为即使这是最新发布的版本,但它还没有更新到生产站点。请检查 release note.
Note: This release is not yet in production but will be deploying over the next few days. These release notes will be updated when it has been deployed to all production sites.
更新时,官方会更新说明。所以最新的可用版本是 2.0.12673
.
当函数应用程序在 运行-time 版本“2.0.12701.0" (FUNCTIONS_EXTENSION_VERSION = ~2 in App Settings)
上 运行ning 时,我收到以下错误。一旦我在应用程序设置中更改 FUNCTIONS_EXTENSION_VERSION to 2.0.12673.0
. 功能开始工作,无需任何代码更改或部署。
错误:
DryIoc.ContainerException : Scope disposed{no name, Parent=disposed{no name, Parent=disposed{no name}}} is disposed and scoped instances are disposed and no longer available. at DryIoc.Throw.It(Int32 error,Object arg0,Object arg1,Object arg2,Object arg3) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 8991 at DryIoc.Scope.TryGet(Object& item,Int32 id) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7881 at DryIoc.Container.InstanceFactory.GetAndUnwrapOrDefault(IScope scope,Int32 factoryId) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 1480 at DryIoc.Container.InstanceFactory.GetInstanceFromScopeChainOrSingletons(IResolverContext r) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 1466 at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType,IfUnresolved ifUnresolved) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 224 at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType,IfUnresolved ifUnresolved) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 195 at DryIoc.Resolver.Resolve[TService](IResolver resolver,IfUnresolved ifUnresolved) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 4742 at DryIoc.Microsoft.DependencyInjection.DryIocAdapter.<>c__DisplayClass3_0.b__0(IResolverContext r) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\DryIocAdapter.cs : 156 at DryIoc.Registrator.<>c__DisplayClass27_0.b__0(IResolverContext r) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 4541 at lambda_method(Closure ,IResolverContext ) at DryIoc.Factory.<>c__DisplayClass26_1.b__2() at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 6596 at DryIoc.Scope.TryGetOrAdd(ImMap
1 items,Int32 id,CreateScopedValue createValue,Int32 disposalOrder) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7840 at DryIoc.Scope.GetOrAdd(Int32 id,CreateScopedValue createValue,Int32 disposalOrder) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7825 at DryIoc.Factory.ApplyReuse(Expression serviceExpr,Request request) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 6595 at DryIoc.Factory.GetExpressionOrDefault(Request request) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 6555 at DryIoc.Factory.GetDelegateOrDefault(Request request) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 6625 at DryIoc.DelegateFactory.GetDelegateOrDefault(Request request) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7731 at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType,Object serviceKey,IfUnresolved ifUnresolved,Type requiredServiceType,Request preResolveParent,Object[] args) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 290 at lambda_method(Closure ) at DryIoc.Scope.TryGetOrAdd(ImMap
1 items,Int32 id,CreateScopedValue createValue,Int32 disposalOrder) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7840 at DryIoc.Scope.GetOrAdd(Int32 id,CreateScopedValue createValue,Int32 disposalOrder) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 7825 at lambda_method(Closure ,IResolverContext ) at DryIoc.Container.ResolveAndCacheDefaultFactoryDelegate(Type serviceType,IfUnresolved ifUnresolved) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 224 at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType,IfUnresolved ifUnresolved) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\DryIoc\Container.cs : 195 at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ScopedServiceProvider.GetService(Type serviceType) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\DependencyInjection\ScopedServiceProvider.cs : 25 at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,Boolean isDefaultParameterRequired) at lambda_method(Closure ,IServiceProvider ,Object[] ) at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IServiceProvider serviceProvider) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 37 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.ActivatorInstanceFactory1.<>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 : 846 at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsyncCore(IFunctionInstanceEx functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 116
更改应用程序设置中的功能 运行-时间版本 (FUNCTIONS_EXTENSION_VERSION =2.0.12673.0) 从默认 运行-时间版本 2.0.12701.0 修复了问题。
这是我的 Function App Startup class,它注册了依赖项。
public class FunctionAppStartup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddJsonFile("secret.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
builder.Services.Configure<ConfigurationManager>(x => config.Bind(x));
builder.Services.AddSingleton<Contracts.IConfiguration>(resolver =>
resolver.GetRequiredService<IOptions<ConfigurationManager>>().Value);
builder.Services.AddScoped<IChannelAdapter, ChannelAdapter>();
builder.Services.AddScoped<ITableStorageManager, TableStorageManager>();
builder.Services.AddSingleton<IDatabaseContext, DatabaseContext>();
builder.Services.AddScoped<IJobRepository, JobRepository>();
}
}
期望我的函数应用程序在最新的 运行 版本上运行 运行,而不是我针对较小的 运行 版本。
从现在开始,您无法使用此运行时版本。
因为即使这是最新发布的版本,但它还没有更新到生产站点。请检查 release note.
Note: This release is not yet in production but will be deploying over the next few days. These release notes will be updated when it has been deployed to all production sites.
更新时,官方会更新说明。所以最新的可用版本是 2.0.12673
.