Azure Durable Functions do not support Keyed Services
Hi all, I am attempting to use keyed services in a .NET 8 project using azure durable functions. My startup in my azure functions project looks like this:
services.AddKeyedTransient<IExampleInterface>("ExampleKey1", (serviceProvider, o) =>
{
var exampleClass = new ExampleClass();
exampleClass.UniqueString = "First Example String";
return exampleClass;
})
services.AddKeyedTransient<IExampleInterface>("ExampleKey2", (serviceProvider, o) =>
{
var exampleClass = new ExampleClass();
exampleClass.UniqueString = "second Example String";
return exampleClass;
})
and my constructor for my orchestration Function looks like this:
private IExampleInterface _example1;
private IExampleInterface _example2;
Public ExampleOrchestrationFunction([FromKeyedServices("ExampleKey1")] IExampleInterface example1, [FromKeyedServices("ExampleKey2")] IExampleInterface example2)
{
_example1 = example1;
_example2 = example2;
}
When my function is triggered, I am receiving the following error:
"This service provider doesn't support keyed services."
I was wondering if azure functions currently do not support the .NET 8 keyed services, or if there is a work around to use them that someone has found, or if it's a bug?
I appreciate the help with this, Dave.
Stack trace
Severity level: Error, Message: 6d6777a6-d51c-4b0d-af74-a0f2e4937484: Function 'RedactedOrchestration (Orchestrator)' failed with an error. Reason: System.InvalidOperationException: This service provider doesn't support keyed services.
at lambda_method1039(Closure, IServiceProvider, Object[])
at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IServiceProvider serviceProvider) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs:line 37
at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 44
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 793
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance, CancellationToken cancellationToken) in D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 104
at Microsoft.Azure.WebJobs.Extensions.DurableTask.TaskOrchestrationShim.InvokeUserCodeAndHandleResults(RegisteredFunctionInfo orchestratorInfo, OrchestrationContext innerContext) in D:\a\_work\1\s\src\WebJobs.Extensions.DurableTask\Listener\TaskOrchestrationShim.cs:line 150. IsReplay: False. State: Failed. HubName: Redacted. AppName: . SlotName: . ExtensionVersion: 2.9.6. SequenceNumber: 22. TaskEventId: -1
Same here when using Function App. Why is such an essential feature not supported in Microsoft's own environment, and is that documented anywhere?!
Same here when using Function App. Why is such an essential feature not supported in Microsoft's own environment, and is that documented anywhere?!
Yeah it's crazy. Might have better luck if this issue is opened in the Azure Host repo https://github.com/Azure/azure-functions-host/issues or if it's an Isolated .NET 8 Function in the dotnet-worker repo https://github.com/Azure/azure-functions-dotnet-worker. They seem to be super slow to respond in this repo.
(Unexpected that the bug issue template don't ask if you are using in-process or isolated super important info to include)