ClearServiceBusInitializer 1.0.1

dotnet add package ClearServiceBusInitializer --version 1.0.1
                    
NuGet\Install-Package ClearServiceBusInitializer -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ClearServiceBusInitializer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ClearServiceBusInitializer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ClearServiceBusInitializer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ClearServiceBusInitializer --version 1.0.1
                    
#r "nuget: ClearServiceBusInitializer, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ClearServiceBusInitializer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ClearServiceBusInitializer&version=1.0.1
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 141 6/14/2025
1.0.0 146 6/5/2025