Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 3.48 KB

File metadata and controls

63 lines (47 loc) · 3.48 KB
title Quickstart - Use the Azure CLI to create a Service Bus queue | Microsoft Docs
description In this quickstart, you learn how to use the Azure CLI to create a Service Bus namespace and then a queue in that namespace.
author spelluru
ms.topic quickstart
ms.date 01/24/2024
ms.author spelluru
ms.devlang azurecli
ms.custom
mode-api
devx-track-azurecli
sfi-ropc-nochange

Use the Azure CLI to create a Service Bus namespace and a queue

This quickstart shows you how to create a Service Bus namespace and a queue using the Azure CLI. It also shows you how to get authorization credentials that a client application can use to send/receive messages to/from the queue.

[!INCLUDE service-bus-queues]

Prerequisites

If you don't have an Azure subscription, you can create a free account before you begin.

In this quickstart, you use Azure Cloud Shell that you can launch after signing in to the Azure portal. For details about Azure Cloud Shell, see Overview of Azure Cloud Shell. You can also install and use Azure PowerShell on your machine.

Provision resources

  1. Sign in to the Azure portal.

  2. Launch Azure Cloud Shell by selecting the icon shown in the following image. Switch to Bash mode if the Cloud Shell is in PowerShell mode.

    :::image type="icon" source="~/reusable-content/ce-skilling/azure/media/cloud-shell/launch-cloud-shell-button.png" alt-text="Button to launch the Azure Cloud Shell." border="false" link="https://shell.azure.com":::

  3. Run the following command to create an Azure resource group. Update the resource group name and the location if you want.

    az group create --name ContosoRG --location eastus
    
  4. Run the following command to create a Service Bus messaging namespace.

    az servicebus namespace create --resource-group ContosoRG --name ContosoSBusNS --location eastus
    
  5. Run the following command to create a queue in the namespace you created in the previous step. In this example, ContosoRG is the resource group you created in the previous step. ContosoSBusNS is the name of the Service Bus namespace created in that resource group.

    az servicebus queue create --resource-group ContosoRG --namespace-name ContosoSBusNS --name ContosoOrdersQueue
    
  6. Run the following command to get the primary connection string for the namespace. You use this connection string to connect to the queue and send and receive messages.

    az servicebus namespace authorization-rule keys list --resource-group ContosoRG --namespace-name ContosoSBusNS --name RootManageSharedAccessKey --query primaryConnectionString --output tsv    
    

    Note down the connection string and the queue name. You use them to send and receive messages.

Next steps

In this article, you created a Service Bus namespace and a queue in the namespace. To learn how to send/receive messages to/from the queue, see one of the following quickstarts in the Send and receive messages section.