|
| 1 | +--- |
| 2 | +title: Create Azure Service Bus namespace and queue using Bicep |
| 3 | +description: 'Quickstart: Create a Service Bus namespace and a queue using Bicep' |
| 4 | +documentationcenter: .net |
| 5 | +author: spelluru |
| 6 | +ms.author: spelluru |
| 7 | +ms.date: 08/24/2022 |
| 8 | +ms.topic: quickstart |
| 9 | +ms.tgt_pltfrm: dotnet |
| 10 | +ms.custom: subject-bicepqs, mode-arm |
| 11 | +--- |
| 12 | + |
| 13 | +# Quickstart: Create a Service Bus namespace and a queue using a Bicep file |
| 14 | + |
| 15 | +This article shows how to use a Bicep file that creates a Service Bus namespace and a queue within that namespace. The article explains how to specify which resources are deployed and how to define parameters that are specified when the deployment is executed. You can use this Bicep file for your own deployments, or customize it to meet your requirements. |
| 16 | + |
| 17 | +[!INCLUDE [About Bicep](../../includes/resource-manager-bicep-quickstart-introduction.md)] |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin. |
| 22 | + |
| 23 | +## Review the Bicep file |
| 24 | + |
| 25 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/servicebus-create-queue/). |
| 26 | + |
| 27 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.servicebus/servicebus-create-queue/main.bicep"::: |
| 28 | + |
| 29 | +The resources defined in the Bicep file include: |
| 30 | + |
| 31 | +- [**Microsoft.ServiceBus/namespaces**](/azure/templates/microsoft.servicebus/namespaces?pivots=deployment-language-bicep) |
| 32 | +- [**Microsoft.ServiceBus/namespaces/queues**](/azure/templates/microsoft.servicebus/namespaces/queues?pivots=deployment-language-bicep) |
| 33 | + |
| 34 | +> [!NOTE] |
| 35 | +> The following ARM templates are available for download and deployment. |
| 36 | +> |
| 37 | +> - [Create a Service Bus namespace with queue and authorization rule](service-bus-resource-manager-namespace-auth-rule.md) |
| 38 | +> - [Create a Service Bus namespace with topic and subscription](service-bus-resource-manager-namespace-topic.md) |
| 39 | +> - [Create a Service Bus namespace](service-bus-resource-manager-namespace.md) |
| 40 | +> - [Create a Service Bus namespace with topic, subscription, and rule](service-bus-resource-manager-namespace-topic-with-rule.md) |
| 41 | +
|
| 42 | +You can find more Bicep/ARM templates from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/?resourceType=Microsoft.Servicebus&pageNumber=1&sort=Popular) |
| 43 | + |
| 44 | +## Deploy the Bicep file |
| 45 | + |
| 46 | +With this Bicep file, you deploy a Service Bus namespace with a queue. |
| 47 | + |
| 48 | +[Service Bus queues](service-bus-queues-topics-subscriptions.md#queues) offer First In, First Out (FIFO) message delivery to one or more competing consumers. |
| 49 | + |
| 50 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 51 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 52 | + |
| 53 | + # [CLI](#tab/CLI) |
| 54 | + |
| 55 | + ```azurecli |
| 56 | + az group create --name exampleRG --location eastus |
| 57 | + az deployment group create --resource-group exampleRG --template-file main.bicep |
| 58 | + ``` |
| 59 | +
|
| 60 | + # [PowerShell](#tab/PowerShell) |
| 61 | +
|
| 62 | + ```azurepowershell |
| 63 | + New-AzResourceGroup -Name exampleRG -Location eastus |
| 64 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep |
| 65 | + ``` |
| 66 | +
|
| 67 | + --- |
| 68 | +
|
| 69 | + You will be prompted to enter the following parameter values: |
| 70 | +
|
| 71 | + - **serviceBusNamespaceName**: Name of the Service Bus namespace. |
| 72 | + - **serviceBusQueueName**: Name of the Queue. |
| 73 | +
|
| 74 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 75 | +
|
| 76 | +## Validate the deployment |
| 77 | +
|
| 78 | +Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. |
| 79 | +
|
| 80 | +# [CLI](#tab/CLI) |
| 81 | +
|
| 82 | +```azurecli-interactive |
| 83 | +az resource list --resource-group exampleRG |
| 84 | +``` |
| 85 | + |
| 86 | +# [PowerShell](#tab/PowerShell) |
| 87 | + |
| 88 | +```azurepowershell-interactive |
| 89 | +Get-AzResource -ResourceGroupName exampleRG |
| 90 | +``` |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## Clean up resources |
| 95 | + |
| 96 | +When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the VM and all of the resources in the resource group. |
| 97 | + |
| 98 | +# [CLI](#tab/CLI) |
| 99 | + |
| 100 | +```azurecli-interactive |
| 101 | +az group delete --name exampleRG |
| 102 | +``` |
| 103 | + |
| 104 | +# [PowerShell](#tab/PowerShell) |
| 105 | + |
| 106 | +```azurepowershell-interactive |
| 107 | +Remove-AzResourceGroup -Name exampleRG |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## Next steps |
| 113 | + |
| 114 | +See the following topic that shows how to create an authorization rule for the namespace/queue: |
| 115 | + |
| 116 | +[Create a Service Bus authorization rule for namespace and queue using an ARM template](service-bus-resource-manager-namespace-auth-rule.md) |
| 117 | + |
| 118 | +Learn how to manage these resources by viewing these articles: |
| 119 | + |
| 120 | +* [Manage Service Bus with PowerShell](service-bus-manage-with-ps.md) |
| 121 | +* [Manage Service Bus resources with the Service Bus Explorer](https://github.com/paolosalvatori/ServiceBusExplorer/releases) |
| 122 | + |
| 123 | +[Authoring Azure Resource Manager templates]: ../azure-resource-manager/templates/syntax.md |
| 124 | +[Service Bus namespace and queue template]: https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.servicebus/servicebus-create-queue/azuredeploy.json/ |
| 125 | +[Azure Quickstart Templates]: https://azure.microsoft.com/resources/templates/?term=service+bus |
| 126 | +[Learn more about Service Bus queues]: service-bus-queues-topics-subscriptions.md |
| 127 | +[Using Azure PowerShell with Azure Resource Manager]: ../azure-resource-manager/management/manage-resources-powershell.md |
| 128 | +[Using the Azure CLI for Mac, Linux, and Windows with Azure Resource Management]: ../azure-resource-manager/management/manage-resources-cli.md |
0 commit comments