FunctionIndexingException thrown when same function method name is used in different classes
See original GitHub issueHaving a [ServiceBusTrigger]
attribute Message
parameter on one or methods with the same name, but in different classes, throws Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method System.ArgumentException: An item with the same key has already been added.
in FunctionIndexer.cs
line 93 when the webjob console app starts.
It appears this broke from version 3.0.22
as 3.0.19
still works OK.
Repro steps
-
Create a Webjob console application and reference version >= 3.0.22.
-
Create two classes
MessageOneHandler
andMessageTwoHandler
. -
Add methods to each class with the same name and containing a ServiceBusTrigger attribute parameter:
HandleMessage([ServiceBusTrigger(...)] Message message) {...}
-
Run the console application
Expected behavior
No exception is thrown and both methods are invoked for the service bus topic / queue they are configured to use.
Actual behavior
Exception above is thrown:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method System.ArgumentException: An item with the same key has already been added.
in FunctionIndexer.cs
line 93:
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(Type type, IFunctionIndexCollector index, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 98
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexProvider.CreateAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexProvider.cs:line 95
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexProvider.GetAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexProvider.cs:line 69
at Microsoft.Azure.WebJobs.Host.Executors.JobHostContextFactory.Create(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\JobHostContextFactory.cs:line 108
at Microsoft.Azure.WebJobs.JobHost.InitializeHostAsync(CancellationToken cancellationToken, TaskCompletionSource`1 initializationTask) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 347
at Microsoft.Azure.WebJobs.JobHost.StartAsyncCore(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 97
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at StudyTravel.File.ServiceBus.Subscribers.Program.Main() in /home/dan/projects/StudyTravel/File/src/StudyTravel.File.ServiceBus.Subscribers/Program.cs:line 51
at StudyTravel.File.ServiceBus.Subscribers.Program.<Main>()
Known workarounds
Use a unique name per method even if in different classes e.g.
public class MessageOneHandler
{
public async Task HandleMessageOne([ServiceBusTrigger(...) Message message) {...}
}
public class MessageTwoHandler
{
public async Task HandleMessageTwo([ServiceBusTrigger(...) Message message) {...}
}
Related information
It appears the changes in FunctionIndexer.cs
in this commit are the cause of the breaking change:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top GitHub Comments
The packages have been deployed. thank you for the patience!
Assingning this to myself to update when deployed.