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

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

先决条件Prerequisites

若要完成本快速入门,需要一个 Azure 订阅。To complete this quickstart, you need an Azure subscription. 如果没有订阅,请在开始之前创建一个试用帐户If you don't have one, create a trial account before you begin.

如果选择在本地安装并使用 Azure CLI,本教程要求运行 Azure CLI 2.0.4 或更高版本。If you choose to install and use Azure CLI locally, this tutorial requires that you are running Azure CLI version 2.0.4 or later. 请运行 az --version 检查版本。Run az --version to check your version. 如需进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install the Azure CLI.

登录 AzureSign in to Azure

如果在本地运行 CLI,请按以下步骤登录到 Azure 并设置当前订阅:If you're running the CLI locally, perform the following steps to sign in to Azure and set your current subscription:

运行以下命令来登录到 Azure:Run the following command to sign in to Azure:

az cloud set -n AzureChinaCloud
az login

设置当前订阅上下文。Set the current subscription context. MyAzureSub 替换为要使用的 Azure 订阅的名称:Replace MyAzureSub with the name of the Azure subscription you want to use:

az account set --subscription MyAzureSub

创建资源组Create a resource group

资源组是 Azure 资源的逻辑集合。A resource group is a logical collection of Azure resources. 所有资源在资源组中进行部署和管理。All resources are deployed and managed in a resource group. 运行以下命令创建资源组:Run the following command to create a resource group:

# Create a resource group. Specify a name for the resource group.
az group create --name <resource group name> --location chinaeast

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

事件中心命名空间提供唯一的范围容器,可以通过其完全限定的域名进行引用,而在该容器中,可以创建一个或多个事件中心。An Event Hubs namespace provides a unique scoping container, referenced by its fully qualified domain name, in which you create one or more event hubs. 若要在资源组中创建命名空间,请运行以下命令:To create a namespace in your resource group, run the following command:

# Create an Event Hubs namespace. Specify a name for the Event Hubs namespace.
az eventhubs namespace create --name <Event Hubs namespace> --resource-group <resource group name> -l <region, for example: China East>

创建事件中心Create an event hub

请运行以下命令,以便创建事件中心:Run the following command to create an event hub:

# Create an event hub. Specify a name for the event hub. 
az eventhubs eventhub create --name <event hub name> --resource-group <resource group name> --namespace-name <Event Hubs namespace>

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

后续步骤Next steps

在本文中,你已创建一个资源组、一个事件中心命名空间和一个事件中心。In this article, you created a resource group, an Event Hubs namespace, and an 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: