Skip to content
service busmessagingintegrationazurecafnaming conventions

Azure Service Bus Naming Conventions: Namespaces, Queues, and Topics

CAF naming for Azure Service Bus. The namespace is a globally unique servicebus.windows.net endpoint (6 to 50 chars); queues, topics, and subscriptions inside are relaxed. Patterns and examples.

Tushar Verma · · 4 min read

An Azure Service Bus namespace name is a globally unique DNS endpoint (<name>.servicebus.windows.net), so it must be 6 to 50 characters, alphanumerics and hyphens, and start with a letter: sbns-payments-prod-eus-001. The queues, topics, and subscriptions inside it are namespace-scoped and relaxed, so keep them short and purpose-named, like sbq-orders.

Service Bus naming follows the same two-layer pattern as SQL and Cosmos DB. The namespace is a globally visible DNS endpoint with strict rules. Everything inside it, queues, topics, and subscriptions, is privately scoped and generous. Name the namespace carefully, then keep the rest short and descriptive.

The pieces and their rules

ResourceCAF prefixLengthCharactersUnique within
Namespacesbns6-50Alphanumerics and hyphensAll of Azure (global)
Queuesbq1-260Alphanumerics, periods, hyphens, underscores, slashesIts namespace
Topicsbt1-260Same as queueIts namespace
Subscriptionsbts1-50Alphanumerics, periods, hyphens, underscoresIts topic

The namespace becomes <name>.servicebus.windows.net, which is why it must be globally unique, start with a letter, and end with a letter or number. Everything inside it is addressed relative to the namespace, so those names only need to be unique within their parent.

Naming the namespace

Use the full CAF pattern:

sbns-{workload}-{environment}-{region}-{instance}
ScenarioNamespace name
Payments messaging, productionsbns-payments-prod-eus-001
Order processing, devsbns-orders-dev-eus-001
Shared integration bus, productionsbns-integration-prod-eus-001

Because the name is globally unique, keep the region abbreviation and instance number for entropy, a generic sbns-orders-prod may already be taken by another tenant. The 6-character minimum is easy to clear with the CAF pattern.

Naming queues, topics, and subscriptions

The namespace name already carries the workload, environment, and region. Repeating that inside is noise. Name queues and topics after the message they carry, and subscriptions after their consumer:

sbns-payments-prod-eus-001
├── sbq-orders               (queue)
├── sbq-notifications        (queue)
└── sbt-order-events         (topic)
    ├── sbts-fulfillment     (subscription for the fulfillment service)
    └── sbts-analytics       (subscription for the analytics pipeline)

Queue and topic names allow slashes, so you can namespace them if you have many: orders/priority, orders/standard. Subscriptions are scoped to a single topic, so name them for the downstream consumer that reads them, which makes the message flow readable at a glance.

Service Bus is one of several messaging services, each with its own namespace and prefixes:

ServiceNamespace prefixEntity prefix
Service Bussbnssbq, sbt, sbts
Event Hubsevhnsevh
Event Grid(topic)evgt, evgd
Relayrly

Event Hubs namespaces follow the same globally-unique, 6 to 50 character rule as Service Bus, since they are also servicebus.windows.net endpoints under the hood.

Naming in Terraform

resource "azurerm_servicebus_namespace" "main" {
  name                = "sbns-${var.workload}-${var.environment}-${var.region}-001"
  resource_group_name = azurerm_resource_group.main.name
  location            = azurerm_resource_group.main.location
  sku                 = "Standard"
}

resource "azurerm_servicebus_queue" "orders" {
  name         = "sbq-orders"
  namespace_id = azurerm_servicebus_namespace.main.id
}

resource "azurerm_servicebus_topic" "order_events" {
  name         = "sbt-order-events"
  namespace_id = azurerm_servicebus_namespace.main.id
}

resource "azurerm_servicebus_subscription" "fulfillment" {
  name               = "sbts-fulfillment"
  topic_id           = azurerm_servicebus_topic.order_events.id
  max_delivery_count = 10
}

The namespace name is built from variables so every environment derives it the same way; the entity names stay short and purpose-driven.

Common mistakes

Repeating the namespace context in queue names. A queue named sbq-payments-prod-orders inside sbns-payments-prod-eus-001 says everything twice. Call it sbq-orders.

A namespace that is not globally unique. Short generic names collide with other tenants. Keep the region and instance number.

Naming subscriptions after the topic instead of the consumer. A subscription is one reader of a topic, so name it for what reads it (sbts-fulfillment), not for the topic it belongs to.

Summary

  • Namespace: 6 to 50 characters, alphanumerics and hyphens, globally unique, it becomes a servicebus.windows.net endpoint
  • Queues and topics: namespace-scoped and relaxed, name them by message type, slashes allowed for hierarchy
  • Subscriptions: topic-scoped, name them for the downstream consumer
  • Build the namespace name from variables in IaC, and keep entities short

Full rules are on the Service Bus namespace naming page. AzureNamer generates namespace and entity names with the right constraints applied. See the SQL and Cosmos DB guides for the same globally-unique endpoint pattern, and the complete CAF guide for the fundamentals.

Try AzureNamer

Generate CAF compliant names for all 200+ Azure resource types, free, no login required.

Open the Generator →