Proposed Pull Request Change

title description author ms.topic ms.tgt_pltfrm ms.date ms.author ms.custom
Create Azure Service Bus resources using templates Use Azure Resource Manager templates to automate the creation of Service Bus resources spelluru article dotnet 09/20/2021 spelluru ['devx-track-arm-template', 'sfi-ropc-nochange']
📄 Document Links
GitHub View on GitHub Microsoft Learn View on Microsoft Learn
Content Truncation Detected
The generated rewrite appears to be incomplete.
Original lines: -
Output lines: -
Ratio: -
Raw New Markdown
Generating updated version of doc...
Rendered New Markdown
Generating updated version of doc...
+0 -0
+0 -0
--- title: Create Azure Service Bus resources using templates description: Use Azure Resource Manager templates to automate the creation of Service Bus resources author: spelluru ms.topic: article ms.tgt_pltfrm: dotnet ms.date: 09/20/2021 ms.author: spelluru ms.custom: - devx-track-arm-template - sfi-ropc-nochange --- # Create Service Bus resources using Azure Resource Manager templates This article describes how to create and deploy Service Bus resources using Azure Resource Manager templates, PowerShell, and the Service Bus resource provider. Azure Resource Manager templates help you define the resources to deploy for a solution, and to specify parameters and variables that enable you to input values for different environments. The template is written in JSON and consists of expressions that you can use to construct values for your deployment. For detailed information about writing Azure Resource Manager templates, and a discussion of the template format, see [structure and syntax of Azure Resource Manager templates](../azure-resource-manager/templates/syntax.md). > [!NOTE] > The examples in this article show how to use Azure Resource Manager to create a Service Bus namespace and messaging entity (queue). For other template examples, visit the [Azure Quickstart Templates gallery][Azure Quickstart Templates gallery] and search for **Service Bus**. [!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)] ## Service Bus Resource Manager templates These Service Bus Azure Resource Manager templates are available for download and deployment. Click the following links for details about each one, with links to the templates on GitHub: * [Create a Service Bus namespace](service-bus-resource-manager-namespace.md) * [Create a Service Bus namespace with queue](service-bus-resource-manager-namespace-queue.md) * [Create a Service Bus namespace with topic and subscription](service-bus-resource-manager-namespace-topic.md) * [Create a Service Bus namespace with queue and authorization rule](service-bus-resource-manager-namespace-auth-rule.md) * [Create a Service Bus namespace with topic, subscription, and rule](service-bus-resource-manager-namespace-topic-with-rule.md) ## Deploy with PowerShell The following procedure describes how to use PowerShell to deploy an Azure Resource Manager template that creates a Standard tier Service Bus namespace, and a queue within that namespace. This example is based on the [Create a Service Bus namespace with queue](https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.servicebus/servicebus-create-queue/azuredeploy.json) template. The approximate workflow is as follows: 1. Install PowerShell. 2. Create the template and (optionally) a parameter file. 3. In PowerShell, log in to your Azure account. 4. Create a new resource group if one does not exist. 5. Test the deployment. 6. If desired, set the deployment mode. 7. Deploy the template. For complete information about deploying Azure Resource Manager templates, see [Deploy resources with Azure Resource Manager templates][Deploy resources with Azure Resource Manager templates]. ### Install PowerShell Install Azure PowerShell by following the instructions in [Getting started with Azure PowerShell](/powershell/azure/get-started-azureps). ### Create a template Clone the repository or copy the [servicebus-create-queue](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.servicebus/servicebus-create-queue/azuredeploy.json) template from GitHub: ```json { "$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "serviceBusNamespaceName": { "type": "string", "metadata": { "description": "Name of the Service Bus namespace" } }, "serviceBusQueueName": { "type": "string", "metadata": { "description": "Name of the Queue" } } }, "variables": { "defaultSASKeyName": "RootManageSharedAccessKey", "authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('serviceBusNamespaceName'), variables('defaultSASKeyName'))]", "sbVersion": "2017-04-01" }, "resources": [ { "apiVersion": "2017-04-01", "name": "[parameters('serviceBusNamespaceName')]", "type": "Microsoft.ServiceBus/Namespaces", "location": "[resourceGroup().location]", "sku": { "name": "Standard" }, "properties": {}, "resources": [ { "apiVersion": "2017-04-01", "name": "[parameters('serviceBusQueueName')]", "type": "Queues", "dependsOn": [ "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]" ], "properties": { "lockDuration": "PT5M", "maxSizeInMegabytes": "1024", "requiresDuplicateDetection": "false", "requiresSession": "false", "defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S", "deadLetteringOnMessageExpiration": "false", "duplicateDetectionHistoryTimeWindow": "PT10M", "maxDeliveryCount": "10", "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S", "enablePartitioning": "false", "enableExpress": "false" } } ] } ], "outputs": { "NamespaceConnectionString": { "type": "string", "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]" }, "SharedAccessPolicyPrimaryKey": { "type": "string", "value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]" } } } ``` ### Create a parameters file (optional) To use an optional parameters file, copy the [servicebus-create-queue](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.servicebus/servicebus-create-queue/azuredeploy.parameters.json) file. Replace the value of `serviceBusNamespaceName` with the name of the Service Bus namespace you want to create in this deployment, and replace the value of `serviceBusQueueName` with the name of the queue you want to create. ```json { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "serviceBusNamespaceName": { "value": "<myNamespaceName>" }, "serviceBusQueueName": { "value": "<myQueueName>" }, "serviceBusApiVersion": { "value": "2017-04-01" } } } ``` For more information, see the [Parameters](../azure-resource-manager/templates/parameter-files.md) article. ### Log in to Azure and set the Azure subscription From a PowerShell prompt, run the following command: ```powershell Connect-AzAccount ``` You are prompted to log on to your Azure account. After logging on, run the following command to view your available subscriptions: ```powershell Get-AzSubscription ``` This command returns a list of available Azure subscriptions. Choose a subscription for the current session by running the following command. Replace `<YourSubscriptionId>` with the GUID for the Azure subscription you want to use: ```powershell Set-AzContext -SubscriptionID <YourSubscriptionId> ``` ### Set the resource group If you do not have an existing resource group, create a new resource group with the **New-AzResourceGroup** command. Provide the name of the resource group and location you want to use. For example: ```powershell New-AzResourceGroup -Name MyDemoRG -Location "West US" ``` If successful, a summary of the new resource group is displayed. ```powershell ResourceGroupName : MyDemoRG Location : westus ProvisioningState : Succeeded Tags : ResourceId : /subscriptions/<GUID>/resourceGroups/MyDemoRG ``` ### Test the deployment Validate your deployment by running the `Test-AzResourceGroupDeployment` cmdlet. When testing the deployment, provide parameters exactly as you would when executing the deployment. ```powershell Test-AzResourceGroupDeployment -ResourceGroupName MyDemoRG -TemplateFile <path to template file>\azuredeploy.json ``` ### Create the deployment To create the new deployment, run the `New-AzResourceGroupDeployment` cmdlet, and provide the necessary parameters when prompted. The parameters include a name for your deployment, the name of your resource group, and the path or URL to the template file. If the **Mode** parameter is not specified, the default value of **Incremental** is used. For more information, see [Incremental and complete deployments](../azure-resource-manager/templates/deployment-modes.md). The following command prompts you for the three parameters in the PowerShell window: ```powershell New-AzResourceGroupDeployment -Name MyDemoDeployment -ResourceGroupName MyDemoRG -TemplateFile <path to template file>\azuredeploy.json ``` To specify a parameters file instead, use the following command: ```powershell New-AzResourceGroupDeployment -Name MyDemoDeployment -ResourceGroupName MyDemoRG -TemplateFile <path to template file>\azuredeploy.json -TemplateParameterFile <path to parameters file>\azuredeploy.parameters.json ``` You can also use inline parameters when you run the deployment cmdlet. The command is as follows: ```powershell New-AzResourceGroupDeployment -Name MyDemoDeployment -ResourceGroupName MyDemoRG -TemplateFile <path to template file>\azuredeploy.json -parameterName "parameterValue" ``` To run a [complete](../azure-resource-manager/templates/deployment-modes.md) deployment, set the **Mode** parameter to **Complete**: ```powershell New-AzResourceGroupDeployment -Name MyDemoDeployment -Mode Complete -ResourceGroupName MyDemoRG -TemplateFile <path to template file>\azuredeploy.json ``` ### Verify the deployment If the resources are deployed successfully, a summary of the deployment is displayed in the PowerShell window: ```powershell DeploymentName : MyDemoDeployment ResourceGroupName : MyDemoRG ProvisioningState : Succeeded Timestamp : 4/19/2017 10:38:30 PM Mode : Incremental TemplateLink : Parameters : Name Type Value =============== ========================= ========== serviceBusNamespaceName String <namespaceName> serviceBusQueueName String <queueName> serviceBusApiVersion String 2017-04-01 ``` ## Next steps You've now seen the basic workflow and commands for deploying an Azure Resource Manager template. For more detailed information, visit the following links: * [Azure Resource Manager overview][Azure Resource Manager overview] * [Deploy resources with Resource Manager templates and Azure PowerShell][Deploy resources with Azure Resource Manager templates] * [Authoring Azure Resource Manager templates](../azure-resource-manager/templates/syntax.md) * [Microsoft.ServiceBus resource types](/azure/templates/microsoft.servicebus/allversions) [Azure Resource Manager overview]: ../azure-resource-manager/management/overview.md [Deploy resources with Azure Resource Manager templates]: ../azure-resource-manager/templates/deploy-powershell.md [Azure Quickstart Templates gallery]: https://azure.microsoft.com/resources/templates/?term=service+bus
Success! Branch created successfully. Create Pull Request on GitHub
Error: