Skip to content

Commit 3a5bacf

Browse files
authored
Merge pull request #230485 from spelluru/ehubfreshness0313-2
Event Hubs quickstarts
2 parents da85ca1 + 33137f0 commit 3a5bacf

File tree

2 files changed

+190
-48
lines changed

2 files changed

+190
-48
lines changed

articles/event-hubs/event-hubs-quickstart-cli.md

Lines changed: 93 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,132 @@
11
---
2-
title: Create an event hub using Azure CLI - Azure Event Hubs | Microsoft Docs
2+
title: Quickstart - Create an event hub using Azure CLI
33
description: This quickstart describes how to create an event hub using Azure CLI and then send and receive events using Java.
44
ms.topic: quickstart
5-
ms.date: 06/18/2021
5+
ms.date: 03/13/2023
66
ms.author: spelluru
77
ms.custom: devx-track-azurecli, mode-api
88
---
99

1010
# Quickstart: Create an event hub using Azure CLI
11+
In this quickstart, you will create an event hub using Azure CLI.
1112

12-
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](event-hubs-about.md) and [Event Hubs features](event-hubs-features.md).
13-
14-
In this quickstart, you create an event hub using Azure CLI.
1513

1614
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
1715

1816
[!INCLUDE [azure-cli-prepare-your-environment.md](~/articles/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)]
1917

2018
- This article requires version 2.0.4 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
2119

22-
## Set the subscription context
23-
24-
The following steps are not required if you're running commands in Cloud Shell. If you're running the CLI locally, perform the following steps to sign in to Azure and set your current subscription:
20+
## Create a resource group
21+
Run the following command to create a resource group. A resource group is a logical collection of Azure resources. All resources are deployed and managed in a resource group.
2522

26-
Set the current subscription context. Replace `MyAzureSub` with the name of the Azure subscription you want to use:
23+
Select **Copy** to copy the command and paste it into the Cloud Shell or CLI window, and run it. Update the resource group name and the region if you like.
2724

2825
```azurecli-interactive
29-
az account set --subscription MyAzureSub
30-
```
31-
32-
## Create a resource group
33-
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:
26+
rgName="contosorg$RANDOM"
27+
region="eastus"
28+
az group create --name $rgName --location $region
29+
```
3430

35-
```azurecli-interactive
36-
# Create a resource group. Specify a name for the resource group.
37-
az group create --name <resource group name> --location eastus
31+
You see the output similar to the following one. You see the resource group name in the `name` field with a random number replacing `$RANDOM`.
32+
33+
```json
34+
{
35+
"id": "/subscriptions/0000000000-0000-0000-0000-000000000000000/resourceGroups/contosorg32744",
36+
"location": "eastus",
37+
"managedBy": null,
38+
"name": "contosorg32744",
39+
"properties": {
40+
"provisioningState": "Succeeded"
41+
},
42+
"tags": null,
43+
"type": "Microsoft.Resources/resourceGroups"
44+
}
3845
```
3946

4047
## Create an Event Hubs namespace
41-
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:
48+
Run the following command to 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. Update the name of the namespace if you like.
4249

4350
```azurecli-interactive
4451
# Create an Event Hubs namespace. Specify a name for the Event Hubs namespace.
45-
az eventhubs namespace create --name <Event Hubs namespace> --resource-group <resource group name> -l <region, for example: East US>
52+
namespaceName="contosoehubns$RANDOM"
53+
az eventhubs namespace create --name $namespaceName --resource-group $rgName -l $region
54+
```
55+
56+
You see the output similar to the following one. You see the name of the namespace in the `name` field.
57+
58+
```json
59+
{
60+
"createdAt": "2023-03-13T20:28:53.037Z",
61+
"disableLocalAuth": false,
62+
"id": "/subscriptions/0000000000-0000-0000-0000-0000000000000000/resourceGroups/contosorg32744/providers/Microsoft.EventHub/namespaces/contosoehubns17861",
63+
"isAutoInflateEnabled": false,
64+
"kafkaEnabled": true,
65+
"location": "East US",
66+
"maximumThroughputUnits": 0,
67+
"metricId": "0000000000-0000-0000-0000-0000000000000000:contosoehubns17861",
68+
"minimumTlsVersion": "1.2",
69+
"name": "contosoehubns17861",
70+
"provisioningState": "Succeeded",
71+
"publicNetworkAccess": "Enabled",
72+
"resourceGroup": "contosorg32744",
73+
"serviceBusEndpoint": "https://contosoehubns17861.servicebus.windows.net:443/",
74+
"sku": {
75+
"capacity": 1,
76+
"name": "Standard",
77+
"tier": "Standard"
78+
},
79+
"status": "Active",
80+
"tags": {},
81+
"type": "Microsoft.EventHub/Namespaces",
82+
"updatedAt": "2023-03-13T20:29:45.637Z",
83+
"zoneRedundant": false
84+
}
4685
```
4786

4887
## Create an event hub
49-
Run the following command to create an event hub:
88+
Run the following command to create an event hub. Update the name of the event hub if you like.
5089

5190
```azurecli-interactive
5291
# Create an event hub. Specify a name for the event hub.
53-
az eventhubs eventhub create --name <event hub name> --resource-group <resource group name> --namespace-name <Event Hubs namespace>
92+
eventhubName="contosoehub$RANDOM"
93+
az eventhubs eventhub create --name $eventhubName --resource-group $rgName --namespace-name $namespaceName
94+
```
95+
96+
You see the output similar to the following one. You see the name of the event hub in the `name` field.
97+
98+
```json
99+
{
100+
"captureDescription": null,
101+
"createdAt": "2023-03-13T20:32:04.457000+00:00",
102+
"id": "/subscriptions/000000000-0000-0000-0000-00000000000000/resourceGroups/contosorg32744/providers/Microsoft.EventHub/namespaces/contosoehubns17861/eventhubs/contosoehub23255",
103+
"location": "eastus",
104+
"messageRetentionInDays": 7,
105+
"name": "contosoehub23255",
106+
"partitionCount": 4,
107+
"partitionIds": [
108+
"0",
109+
"1",
110+
"2",
111+
"3"
112+
],
113+
"resourceGroup": "contosorg32744",
114+
"status": "Active",
115+
"systemData": null,
116+
"type": "Microsoft.EventHub/namespaces/eventhubs",
117+
"updatedAt": "2023-03-13T20:32:04.727000+00:00"
118+
}
54119
```
55120

56121
Congratulations! You have used Azure CLI to create an Event Hubs namespace, and an event hub within that namespace.
57122

123+
## Clean up resources
124+
If you want to keep this event hub so that you can test sending and receiving events, ignore this section. Otherwise, run the following command to delete the resource group. This command deletes all the resources in the resource group and the resource group itself.
125+
126+
```azurecli-interactive
127+
az group delete --name $rgName
128+
```
129+
58130
## Next steps
59131

60132
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:
@@ -66,8 +138,3 @@ In this article, you created a resource group, an Event Hubs namespace, and an e
66138
- [Go](event-hubs-go-get-started-send.md)
67139
- [C (send only)](event-hubs-c-getstarted-send.md)
68140
- [Apache Storm (receive only)](event-hubs-storm-getstarted-receive.md)
69-
70-
[create a free account]: https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio
71-
[Install the Azure CLI]: /cli/azure/install-azure-cli
72-
[az group create]: /cli/azure/group#az_group_create
73-
[fully qualified domain name]: https://wikipedia.org/wiki/Fully_qualified_domain_name

articles/event-hubs/event-hubs-quickstart-powershell.md

Lines changed: 97 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,135 @@
11
---
2-
title: 'Quickstart: Create an event hub using PowerShell - Azure Event Hubs'
2+
title: 'Quickstart: Create an event hub using PowerShell'
33
description: This quickstart describes how to create an event hub using Azure PowerShell and then send and receive events using .NET Standard SDK.
44
ms.topic: quickstart
5-
ms.date: 09/28/2021
5+
ms.date: 03/13/2023
66
ms.custom: devx-track-azurepowershell, mode-api
77
---
88

99
# Quickstart: Create an event hub using Azure PowerShell
10-
11-
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](event-hubs-about.md) and [Event Hubs features](event-hubs-features.md).
12-
1310
In this quickstart, you create an event hub using Azure PowerShell.
1411

1512
## Prerequisites
16-
17-
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
18-
19-
To complete this tutorial, make sure you have:
20-
21-
- Azure subscription. If you don't have one, [create a free account][] before you begin.
22-
- [Visual Studio 2019](https://www.visualstudio.com/vs).
23-
- [.NET Core SDK](https://dotnet.microsoft.com/download), version 2.0 or later.
13+
An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2414

2515
[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)]
2616

2717
If you're using PowerShell locally, you must run the latest version of PowerShell to complete this quickstart. If you need to install or upgrade, see [Install and Configure Azure PowerShell](/powershell/azure/install-az-ps).
2818

2919
## Create a resource group
20+
Run the following command to create a resource group. A resource group is a logical collection of Azure resources. All resources are deployed and managed in a resource group.
3021

31-
A resource group is a logical collection of Azure resources, and you need a resource group to create an event hub.
22+
If you're using Azure Cloud Shell, switch to **PowerShell** from **Bash** in the upper left corner. Select **Copy** to copy the command and paste it into the Cloud Shell, and run it.
3223

33-
The following example creates a resource group in the East US region. Replace `myResourceGroup` with the name of the resource group you want to use:
24+
The following example creates a resource group in the East US region. Replace `myResourceGroup` with the name of the resource group you want to use.
3425

3526
```azurepowershell-interactive
36-
New-AzResourceGroup –Name myResourceGroup –Location eastus
27+
$rgName="myResourceGroup$(Get-Random)"
28+
$region="eastus"
29+
New-AzResourceGroup –Name $rgName –Location $region
30+
```
31+
You see the output similar to the following one. You see the name of the resource with the random number suffix.
32+
33+
```bash
34+
ResourceGroupName : myResourceGroup1625872532
35+
Location : eastus
36+
ProvisioningState : Succeeded
37+
Tags :
38+
ResourceId : /subscriptions/0000000000-0000-0000-0000-0000000000000/resourceGroups/myResourceGroup1625872532
3739
```
3840

3941
## Create an Event Hubs namespace
40-
41-
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. Replace `namespace_name` with a unique name for your namespace:
42+
Run the following command to create an Event Hubs namespace in the resource group. An Event Hubs namespace provides a unique fully qualified domain name in which you can create one or more event hubs. Update the value of the namespace if you like.
4243

4344
```azurepowershell-interactive
44-
New-AzEventHubNamespace -ResourceGroupName myResourceGroup -NamespaceName namespace_name -Location eastus
45+
$namespaceName="myNamespace$(Get-Random)"
46+
New-AzEventHubNamespace -ResourceGroupName $rgName -NamespaceName $namespaceName -Location $region
47+
```
48+
49+
You see the output similar to the following one. You see the name of the namespace in the `Name` field.
50+
51+
```bash
52+
Name : myNamespace143349827
53+
Id : /subscriptions/0000000000-0000-0000-0000-00000000000000/resourceGroups/myResourceGroup162587253
54+
2/providers/Microsoft.EventHub/namespaces/myNamespace143349827
55+
ResourceGroupName : myResourceGroup1625872532
56+
Location : East US
57+
Sku : Name : Standard , Capacity : 1 , Tier : Standard
58+
Tags :
59+
ProvisioningState : Succeeded
60+
Status : Active
61+
CreatedAt : 3/13/2023 10:22:54 PM
62+
UpdatedAt : 3/13/2023 10:23:41 PM
63+
ServiceBusEndpoint : https://myNamespace143349827.servicebus.windows.net:443/
64+
Enabled : True
65+
KafkaEnabled : True
66+
IsAutoInflateEnabled : False
67+
MaximumThroughputUnits : 0
68+
ZoneRedundant : False
69+
ClusterArmId :
70+
DisableLocalAuth : False
71+
MinimumTlsVersion : 1.2
72+
KeySource :
73+
Identity :
74+
IdentityType :
75+
IdentityId :
76+
EncryptionConfig :
4577
```
4678

4779
## Create an event hub
4880

49-
Now that you have an Event Hubs namespace, create an event hub within that namespace:
50-
Allowed period for `MessageRetentionInDays` is between 1 and 7 days.
81+
Now that you have an Event Hubs namespace, create an event hub within that namespace by running the following command.
5182

5283
```azurepowershell-interactive
53-
New-AzEventHub -ResourceGroupName myResourceGroup -NamespaceName namespace_name -EventHubName eventhub_name -MessageRetentionInDays 3
84+
$ehubName="myEventHub"
85+
New-AzEventHub -ResourceGroupName $rgName -NamespaceName $namespaceName -EventHubName $ehubName
86+
```
87+
You see output similar to the following one.
88+
89+
```bash
90+
ArchiveNameFormat :
91+
BlobContainer :
92+
CaptureEnabled :
93+
CreatedAt : 3/13/2023 10:26:07 PM
94+
DataLakeAccountName :
95+
DataLakeFolderPath :
96+
DataLakeSubscriptionId :
97+
DestinationName :
98+
Encoding :
99+
Id : /subscriptions/00000000000-0000-0000-0000-00000000000000/resourceGroups/myResourceGroup162
100+
5872532/providers/Microsoft.EventHub/namespaces/myNamespace143349827/eventhubs/myEven
101+
tHub
102+
IntervalInSeconds :
103+
Location : eastus
104+
MessageRetentionInDays : 7
105+
Name : myEventHub
106+
PartitionCount : 4
107+
PartitionId : {0, 1, 2, 3}
108+
ResourceGroupName : myResourceGroup1625872532
109+
SizeLimitInBytes :
110+
SkipEmptyArchive :
111+
Status : Active
112+
StorageAccountResourceId :
113+
SystemDataCreatedAt :
114+
SystemDataCreatedBy :
115+
SystemDataCreatedByType :
116+
SystemDataLastModifiedAt :
117+
SystemDataLastModifiedBy :
118+
SystemDataLastModifiedByType :
119+
Type : Microsoft.EventHub/namespaces/eventhubs
120+
UpdatedAt : 3/13/2023 10:26:07 PM
54121
```
55122

56123
Congratulations! You have used Azure PowerShell to create an Event Hubs namespace, and an event hub within that namespace.
57124

125+
## Clean up resources
126+
If you want to keep this event hub so that you can test sending and receiving events, ignore this section. Otherwise, run the following command to delete the resource group. This command deletes all the resources in the resource group and the resource group itself.
127+
128+
```azurepowershell-interactive
129+
Remove-AzResourceGroup $rgName
130+
```
131+
132+
58133
## Next steps
59134

60135
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:

0 commit comments

Comments
 (0)