快速入门:使用 Azure PowerShell 创建事件中心Quickstart: Create an event hub using Azure PowerShell

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 PowerShell 创建事件中心。In this quickstart, you create an event hub using Azure PowerShell.

先决条件Prerequisites

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

若要完成本教程,请确保做好以下准备:To complete this tutorial, make sure you have:

如果在本地使用 PowerShell,必须运行最新版本的 PowerShell 才能完成本快速入门。If you're using PowerShell locally, you must run the latest version of PowerShell to complete this quickstart. 如需进行安装或升级,请参阅安装和配置 Azure PowerShellIf you need to install or upgrade, see Install and Configure Azure PowerShell.

创建资源组Create a resource group

资源组是 Azure 资源的逻辑集合,需有一个资源组才能创建事件中心。A resource group is a logical collection of Azure resources, and you need a resource group to create an event hub.

以下示例在中国东部区域中创建一个资源组。The following example creates a resource group in the China East region. myResourceGroup 替换为要使用的资源组的名称:Replace myResourceGroup with the name of the resource group you want to use:

New-AzResourceGroup -Name myResourceGroup -Location chinaeast

创建事件中心命名空间Create an Event Hubs namespace

创建资源组后,在该资源组中创建事件中心命名空间。Once your resource group is made, create an Event Hubs namespace within that resource group. 事件中心命名空间提供唯一的完全限定域名,可在其中创建事件中心。An Event Hubs namespace provides a unique fully-qualified domain name in which you can create your event hub. namespace_name 替换为命名空间的唯一名称:Replace namespace_name with a unique name for your namespace:

New-AzEventHubNamespace -ResourceGroupName myResourceGroup -NamespaceName namespace_name -Location chinaeast

创建事件中心Create an event hub

创建事件中心命名空间后,在该命名空间中创建事件中心:Now that you have an Event Hubs namespace, create an event hub within that namespace:
MessageRetentionInDays 的允许期限为 1 到 7 天。Allowed period for MessageRetentionInDays is between 1 and 7 days.

New-AzEventHub -ResourceGroupName myResourceGroup -NamespaceName namespace_name -EventHubName eventhub_name -MessageRetentionInDays 3

祝贺你!Congratulations! 现已使用 Azure PowerShell 创建了一个事件中心命名空间,并在该命名空间中创建了一个事件中心。You have used Azure PowerShell to create an Event Hubs namespace, and an event hub within that namespace.

后续步骤Next steps

在本文中,我们已创建事件中心命名空间,并使用示例应用程序从事件中心发送和接收事件。In this article, you created the Event Hubs namespace, and used sample applications to send and receive events from your event hub. 有关如何将事件发送到事件中心(或)从事件中心接收事件的分步说明,请参阅“发送和接收事件”教程:For step-by-step instructions to send events to (or) receive events from an event hub, see the Send and receive events tutorials: