ClearServiceBusInitializer 1.0.1
dotnet add package ClearServiceBusInitializer --version 1.0.1
NuGet\Install-Package ClearServiceBusInitializer -Version 1.0.1
<PackageReference Include="ClearServiceBusInitializer" Version="1.0.1" />
<PackageVersion Include="ClearServiceBusInitializer" Version="1.0.1" />
<PackageReference Include="ClearServiceBusInitializer" />
paket add ClearServiceBusInitializer --version 1.0.1
#r "nuget: ClearServiceBusInitializer, 1.0.1"
#addin nuget:?package=ClearServiceBusInitializer&version=1.0.1
#tool nuget:?package=ClearServiceBusInitializer&version=1.0.1
Azure Service Bus Provisioning Tool
Introduction
This tool automates the provisioning of Azure Service Bus resources�queues, topics, subscriptions, and rules�at application startup. It's designed for teams without dedicated infrastructure or DevOps support, where managing messaging resources across multiple environments can become repetitive and error-prone.
Ideal for microservices and distributed systems, this lightweight utility ensures that your application's required Service Bus entities are present and correctly configured before the app starts. Simply provide a connection string�no additional infrastructure tooling or manual setup needed.
How It Works
This tool uses a code-first, fluent configuration approach to declare Service Bus resources. The provisioning process runs during application startup, validating and creating any missing entities automatically.
1. Define a Service Bus Context
Implement a class that defines your messaging infrastructure using the fluent API:
public class ServiceBusContext : IServiceBusContext
{
public string Name => "MyApp ServiceBus";
public void BuildServiceBusResource(ServiceBusResource serviceBusResource)
{
// Define a queue
serviceBusResource.AddQueue("Sample Queue 1");
// Define a topic with multiple subscriptions
serviceBusResource.AddTopic("Sample Topic 1")
.AddSubscription("Sample Subscription 1", "Filter-1")
.AddSubscription("Sample Subscription 2", "Filter-2")
.AddSubscription("Sample Subscription 3", "Filter-3");
// Define another topic
serviceBusResource.AddTopic("Sample Topic 2")
.AddSubscription("Sample Subscription 1", "Filter-1")
.AddSubscription("Sample Subscription 2", "Filter-2", "Filter-3");
}
}
Each method corresponds directly to Azure Service Bus entities, and SQL-like filters can be added to subscriptions for fine-grained message routing.
2. Register the Context in Your Application
In Program.cs
, register the context using the provided extension method:
builder.Services.AddServiceBusContext<ServiceBusContext>("your-service-bus-connection-string");
3. Provision Resources at Startup
Provision the declared Service Bus resources at app startup:
await app.CreateServiceBusResource();
This step ensures that all required queues, topics, subscriptions, and rules are created or verified before the application starts processing messages.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Azure.Messaging.ServiceBus (>= 7.19.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.