快速入门:使用 Azure 资源管理器模板创建事件中心Quickstart: Create an event hub by using an Azure Resource Manager template

Azure 事件中心是一个大数据流式处理平台和事件引入服务,每秒能够接收和处理数百万个事件。Azure Event Hubs is a Big Data streaming platform and event ingestion service, capable of receiving and processing millions of events per second. 事件中心可以处理和存储分布式软件和设备生成的事件、数据或遥测。Event Hubs can process and store events, data, or telemetry produced by distributed software and devices. 可以使用任何实时分析提供程序或批处理/存储适配器转换和存储发送到数据中心的数据。Data sent to an event hub can be transformed and stored using any real-time analytics provider or batching/storage adapters. 有关事件中心的详细概述,请参阅事件中心概述事件中心功能For detailed overview of Event Hubs, see Event Hubs overview and Event Hubs features.

在此快速入门中,使用 Azure 资源管理器模板创建事件中心。In this quickstart, you create an event hub by using an Azure Resource Manager template. 部署 Azure 资源管理器模板以创建包含一个事件中心的类型为事件中心的命名空间。You deploy an Azure Resource Manager template to create a namespace of type Event Hubs, with one event hub. 本文介绍如何定义要部署的资源以及如何定义执行部署时指定的参数。The article shows how to define which resources are deployed and how to define parameters that are specified when the deployment is executed. 可将此模板用于自己的部署,或自定义此模板以满足要求。You can use this template for your own deployments, or customize it to meet your requirements. 有关创建模板的信息,请参阅创作 Azure 资源管理器模板For information about creating templates, see Authoring Azure Resource Manager templates.

如果没有 Azure 订阅,请在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

创建事件中心Create an event hub

在此快速入门中,使用现有资源管理器模板In this quickstart, you use an existing Resource Manager template.

若要部署模板,请执行以下操作:To deploy the template:

  1. 从以下代码块中选择“试用” ,然后按照说明登录 Azure CLI。Select Try it from the following code block, and then follow the instructions to sign in to the Azure CLI.

    $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-docs-json-samples/master/101-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.

  2. 选择“复制”以复制 PowerShell 脚本。 Select Copy to copy the PowerShell script.

  3. 右键单击 shell 控制台,然后选择“粘贴” 。Right-click the shell console, and then select Paste.

验证部署Verify the deployment

若要验证部署,可以从 Azure 门户打开资源组,也可以使用以下 Azure PowerShell 脚本。To verify the deployment, you can either open the resource group from the Azure portal, or use the following Azure PowerShell script.

$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 ..."

清理资源Clean up resources

不再需要 Azure 资源时,请通过删除资源组来清理部署的资源。When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group.

$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 ..."

后续步骤Next steps

在本文中,你创建了一个事件中心命名空间,并在该命名空间中创建了一个事件中心。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: