Skip to content

Commit 209fd6e

Browse files
committed
Updated PS quickstart
1 parent 8f245fd commit 209fd6e

File tree

1 file changed

+88
-14
lines changed

1 file changed

+88
-14
lines changed

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

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,122 @@
22
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-
In this quickstart, you will create an event hub using Azure PowerShell.
10+
In this quickstart, you create an event hub using Azure PowerShell.
1111

1212
## Prerequisites
1313
An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
1414

15-
[!INCLUDE [azure-powershell-prepare-your-environment.md](~/articles/reusable-content/azure-powershell/azure-powershell-prepare-your-environment.md)]
16-
17-
1815
[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)]
1916

2017
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).
2118

2219
## 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.
2321

24-
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.
2523

26-
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.
2725

2826
```azurepowershell-interactive
29-
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
3039
```
3140

3241
## Create an Event Hubs namespace
33-
34-
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.
3543

3644
```azurepowershell-interactive
37-
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 :
3877
```
3978

4079
## Create an event hub
4180

42-
Now that you have an Event Hubs namespace, create an event hub within that namespace:
43-
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.
4482

4583
```azurepowershell-interactive
46-
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
47121
```
48122

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

0 commit comments

Comments
 (0)