title | description | ms.topic | ms.custom | ms.date |
---|---|---|---|---|
Quickstart: Create an Azure event hub with consumer group |
Quickstart: Create an Event Hubs namespace with an event hub and a consumer group using Azure Resource Manager templates |
quickstart |
subject-armqs, mode-arm, devx-track-arm-template |
06/08/2021 |
In this quickstart, you create an event hub by using an Azure Resource Manager template (ARM template). You deploy an ARM template to create a namespace of type Event Hubs, with one event hub.
- If you don't have an Azure subscription, create a free account before you begin.
- If you're new to Azure Event Hubs, see Event Hubs overview and Event Hubs features.
The template used in this quickstart is from Azure Quickstart Templates.
:::code language="json" source="~/quickstart-templates/quickstarts/microsoft.eventhub/eventhubs-create-namespace-and-eventhub/azuredeploy.json":::
The resources defined in the template include:
To find more template samples, see Azure Quickstart Templates.
-
If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template opens in the Azure portal.
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.eventhub%2Feventhubs-create-namespace-and-eventhub%2Fazuredeploy.json":::
-
Select an existing resource group or create a resource group and select it.
-
Select the region.
-
Enter a unique name for the project. This name is used to generate names for an Event Hubs namespace and an event hub in the namespace.
-
Select Review + create.
-
On the Review + create page, select Create.
To deploy the template using Azure Cloud Shell:
-
Select Open Cloud Shell from the following code block, and then follow the instructions to sign in to the Azure Cloud Shell.
$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names" $location = Read-Host -Prompt "Enter the location (i.e. centralus)" $resourceGroupName = "${projectName}rg" $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.eventhub/eventhubs-create-namespace-and-eventhub/azuredeploy.json" New-AzResourceGroup -Name $resourceGroupName -Location $location New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -projectName $projectName Write-Host "Press [ENTER] to continue ..."
It takes a few moments to create an event hub.
-
Select Copy to copy the PowerShell script.
-
Right-click the shell console, and then select Paste.
-
Press ENTER to run the commands.
To verify the deployment, you can either open the resource group from the Azure portal, or use the following Azure PowerShell script. If the Cloud Shell is still open, you don't need to copy/run the first line (Read-Host).
$projectName = Read-Host -Prompt "Enter the same project name that you used in the last procedure"
$resourceGroupName = "${projectName}rg"
$namespaceName = "${projectName}ns"
Get-AzEventHub -ResourceGroupName $resourceGroupName -Namespace $namespaceName
Write-Host "Press [ENTER] to continue ..."
When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group. If the Cloud Shell is still open, you don't need to copy/run the first line (Read-Host).
$projectName = Read-Host -Prompt "Enter the same project name that you used in the last procedure"
$resourceGroupName = "${projectName}rg"
Remove-AzResourceGroup -ResourceGroupName $resourceGroupName
Write-Host "Press [ENTER] to continue ..."
In this article, you created an Event Hubs namespace, and an event hub in the namespace. For step-by-step instructions to send events to (or) receive events from an event hub, see the Send and receive events tutorials: