Skip to content
Docs Try Aspire
Docs Try

Get started with the Azure Service Bus integrations

Azure Service Bus logo

Azure Service Bus is a fully managed enterprise message broker with message queues and publish-subscribe topics. The Aspire Azure Service Bus integration lets you model a Service Bus namespace and its queues, topics, and subscriptions as first-class resources in your AppHost, then hand the connection information to any consuming app — regardless of language.

Adding Azure Service Bus through Aspire — rather than wiring up connection strings and environment variables by hand — gives you:

  • Local emulator support. Aspire can run the Azure Service Bus Emulator as a container for local development, so you can develop and test messaging flows without an Azure subscription.
  • Consistent connection info across languages. Once you reference a Service Bus resource from a consuming app, Aspire injects connection properties as environment variables in a predictable format that works from C#, TypeScript, Python, Go, or any other language.
  • Built-in health checks. The hosting integration automatically registers a health check so the dashboard and your orchestrator can tell when the Service Bus resource is ready.
  • Dashboard observability. Service Bus resources appear in the Aspire dashboard with logs, status, and telemetry alongside your other services.
  • A first-class C# client integration. C# apps can use the Aspire.Azure.Messaging.ServiceBus package for automatic dependency injection of ServiceBusClient, health checks, and OpenTelemetry.
  • Role-based access control. When provisioning in Azure, Aspire automatically generates Bicep that assigns the Azure Service Bus Data Owner role to your app’s managed identity.

The Azure Service Bus integration has two sides: a hosting integration that you use in your AppHost to model the namespace and its resources, and a connection story for consuming apps that reference those resources.

architecture-beta

  group apphost(server)[AppHost]
  group consumer(server)[Consuming app]

  service hosting(server)[Hosting integration] in apphost
  service namespace(logos:microsoft-azure)[Service Bus namespace] in apphost
  service queue(server)[Queue or topic] in apphost

  service client(iconoir:server-connection)[Client integration] in consumer
  service app(server)[App] in consumer

  hosting:R --> L:namespace
  namespace:R --> L:queue
  queue:R --> L:client
  client:R --> L:app

The hosting integration lives in your AppHost project and models the Azure Service Bus namespace, queues, topics, and subscriptions as resources. The client integration lives in each consuming app and uses the connection information Aspire injects to talk to Service Bus.

Getting there is a two-step process: model the Service Bus resources in your AppHost, then connect from each app that needs them.

  1. Add the Azure Service Bus hosting integration to your AppHost, then declare a Service Bus namespace and reference its queues or topics from the apps that need them. The Azure Service Bus Hosting integration article walks through every capability — adding queues, topics, subscriptions, the local emulator, existing namespaces, and provisioning customization — with side-by-side C# and TypeScript examples.

    Set up Azure Service Bus in the AppHost

  2. When you reference a Service Bus resource from a consuming app, Aspire injects its connection information as environment variables. See Connect to Azure Service Bus for the connection properties reference and per-language examples for C#, Go, Python, and TypeScript — including the full C# client integration.

    Connect to Azure Service Bus