I want to use rabbitmq in an Azure function project
The code I put in the startup.cs is as follows
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddHttpClient();
builder.Services.AddApplication();
builder.Services.AddInfrastructure();
builder.Services.AddTransient<ReporterAuthenticationRequestHandler>();
builder.Services.AddHttpClient<IReporterApiService, ReporterApiService>()
.AddHttpMessageHandler<ReporterAuthenticationRequestHandler>();
#region Cap
builder.Services.AddCap(options =>
{
options.UseMongoDB("mongodb://localhost:27017");
options.UseRabbitMQ(x =>
{
x.HostName = "localhost";
x.UserName = "guest";
x.Password = "guest";
x.Port = 5672;
});
});
#endregion
}
}
But I get an error:
A host error has occurred during startup operation '7b42aad5-f38c-4062-b255-4ccaa12754ea'.[2022-12-01T06:57:44.400Z] func: Invalid host services. Microsoft.Azure.WebJobs.Script.WebHost: The following service registrations did not match the expected services:[2022-12-01T06:57:44.400Z] [Invalid] ServiceType: Microsoft.Extensions.Hosting.IHostedService, Lifetime: Singleton, ImplementationFactory: System.Func2[System.IServiceProvider,DotNetCore.CAP.Internal.Bootstrapper].Value cannot be null. (Parameter 'provider')
Do you know what I should do?