How to add virtual host when creating .Net Aspire RabbitMQ Container?
var RabbitMQ = builder.AddRabbitMQContainer("messagingRabbitMQ");
Code I'm using to connect from the client apps.
var connection = registrationContext.GetRequiredService<IConnection>();
configurator.Host(new Uri($"amqp://{connection.Endpoint.HostName}:{connection.Endpoint.Port}"),
rabbitMqConfiguration.VirtualHost, host =>
{
host.Username(rabbitMqConfiguration.Username);
host.Password(DefaultSettings.Instance.RabbitMqPassword);
});
If you want to specify a virtual host for RabbitMQ, you usually include it as part of the connection string when setting up your RabbitMQ client.
Here's an example of how you might configure RabbitMQ in a .NET application with a virtual host: