Skip to content

Commit 74e38e2

Browse files
committed
Add Event Hub tutorial for Cloud HSM and standardize placeholders
1 parent 9612fd0 commit 74e38e2

5 files changed

Lines changed: 285 additions & 6 deletions

File tree

articles/cloud-hsm/secure-cloud-hsm.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn best practices for securing Azure Cloud HSM to help protect c
44
author: msmbaldwin
55
ms.service: azure-cloud-hsm
66
ms.topic: conceptual
7-
ms.date: 03/31/2026
7+
ms.date: 04/08/2026
88
ai-usage: ai-assisted
99
ms.custom: horz-security
1010
ms.author: mbaldwin
@@ -88,6 +88,8 @@ Proper handling of key storage limits, key wrapping security, key attributes, an
8888

8989
- **Configure operation event logging**: Operation event logging is vital for HSM security. It provides an immutable record of access and operations for accountability, traceability, and regulatory compliance. It helps detect unauthorized access, investigate incidents, and identify anomalies, to help ensure the integrity and confidentiality of cryptographic operations. To maintain security and privacy, logs exclude sensitive data (such as key IDs, key names, and user details). They capture HSM operations, timestamps, and metadata, but they can't determine success or failure because the HSM operation occurs within the inner TLS channel. See [Tutorial: Operation event logging in Azure Cloud HSM](tutorial-operation-event-logging.md).
9090

91+
- **Stream logs to Event Hub for real-time processing**: For real-time log processing and integration with downstream SIEM systems or custom analytics pipelines, configure Event Hub as an additional destination for your diagnostic settings. See [Tutorial: Configure Event Hub for Azure Cloud HSM](tutorial-configure-event-hub.md).
92+
9193
## Backup and recovery
9294

9395
Azure Cloud HSM provides high availability through clustered HSMs that synchronize keys and policies while automatically migrating workloads during failures.

articles/cloud-hsm/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ items:
1515
items:
1616
- name: Operation event logging
1717
href: tutorial-operation-event-logging.md
18+
- name: Configure Event Hub for logging
19+
href: tutorial-configure-event-hub.md
1820
- name: Backup and restore
1921
href: backup-restore.md
2022
- name: Certificate storage

articles/cloud-hsm/troubleshoot.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: keithp
55
manager: davinune
66
ms.service: azure-cloud-hsm
77
ms.topic: troubleshooting-general
8-
ms.date: 03/26/2026
8+
ms.date: 04/08/2026
99
ms.author: keithp
1010
---
1111

@@ -406,15 +406,15 @@ ED25519 keys are typically used for self-signed certificates or in certificate s
406406

407407
### Can I use azcloudhsm_util to generate RSA and EC keys before using the Azure Cloud HSM OpenSSL engine to generate a CSR?
408408

409-
Yes. You can run the following `azcloudhsm_util` commands to create an RSA or EC key and then extract the private key to a fake PEM format. Replace `{PRIVATE_KEY_HANDLE}` with the private key handle of the RSA or EC key that you created.
409+
Yes. You can run the following `azcloudhsm_util` commands to create an RSA or EC key and then extract the private key to a fake PEM format. Replace `<private-key-handle>` with the private key handle of the RSA or EC key that you created.
410410

411411
The private key metadata file in PEM format doesn't contain any sensitive private key materials. The metadata identifies the private key, and only the OpenSSL engine for Azure Cloud HSM understands this file.
412412

413413
Use this command to create an RSA key:
414414

415415
```bash
416416
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 genRSAKeyPair -m 2048 -e 65537 -l labelRSATest
417-
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 getCaviumPrivKey -k {PRIVATE_KEY_HANDLE} -out web_server_fake_PEM.key
417+
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 getCaviumPrivKey -k <private-key-handle> -out web_server_fake_PEM.key
418418
openssl req -new -key web_server_fake_PEM.key -out web_server.csr -engine azcloudhsm_openssl
419419
openssl x509 -req -days 365 -in web_server.csr -signkey web_server_fake_PEM.key -out web_server.crt -engine azcloudhsm_openssl
420420
```
@@ -423,7 +423,7 @@ Use this command to create an EC key:
423423

424424
```bash
425425
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 genECCKeyPair -i 2 -l labelECTest
426-
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 getCaviumPrivKey -k {PRIVATE_KEY_HANDLE} -out web_server_fake_PEM.key
426+
./azcloudhsm_util singlecmd loginHSM -u CU -p user1234 -s cu1 getCaviumPrivKey -k <private-key-handle> -out web_server_fake_PEM.key
427427
openssl req -new -key web_server_fake_PEM.key -out web_server.csr -engine azcloudhsm_openssl
428428
openssl x509 -req -days 365 -in web_server.csr -signkey web_server_fake_PEM.key -out web_server.crt -engine azcloudhsm_openssl
429429
```
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
---
2+
title: Tutorial - Configure Event Hub for Azure Cloud HSM
3+
description: Learn how to configure Azure Event Hubs as a destination for Azure Cloud HSM operation event logs for real-time streaming and downstream processing.
4+
author: keithp
5+
manager: keithp
6+
ms.service: azure-cloud-hsm
7+
ms.topic: tutorial
8+
ms.date: 04/08/2026
9+
ms.author: keithp
10+
11+
#Customer Intent: As an IT pro, I want to stream Azure Cloud HSM operation logs to Event Hub for real-time processing and integration with downstream systems.
12+
13+
---
14+
15+
# Tutorial: Configure Event Hub for Azure Cloud HSM
16+
17+
If you configured operation event logging for Azure Cloud HSM, you already have a working diagnostic setting on your Cloud HSM cluster that routes `HsmServiceOperations` logs to Storage and Log Analytics. Adding Event Hub is simply adding a third destination to that same diagnostic setting or creating a new one that targets Event Hub.
18+
19+
Azure Monitor diagnostic settings support multiple destinations simultaneously. Since your Log Analytics pipeline already proves that log emission from Cloud HSM is working, Event Hub becomes another sink receiving the same `HsmServiceOperations` category.
20+
21+
In this tutorial, you:
22+
23+
> [!div class="checklist"]
24+
>
25+
> - Create an Event Hub namespace and event hub for Cloud HSM logs.
26+
> - Configure authorization rules with least-privilege permissions.
27+
> - Update diagnostic settings to stream logs to Event Hub.
28+
> - Verify that Event Hub receives Cloud HSM operation events.
29+
30+
## Prerequisites
31+
32+
- An Azure Cloud HSM resource that's deployed and activated. For more information, see the [Azure Cloud HSM onboarding guide](onboarding-guide.md).
33+
- Diagnostic settings emitting operation event logs to Storage and Log Analytics. For more information, see [Configure and query operation event logging for Azure Cloud HSM](tutorial-operation-event-logging.md).
34+
- `Contributor` or `Monitoring Contributor` role on the Cloud HSM resource group.
35+
36+
## Verify the logs resource group exists
37+
38+
Event Hub should deploy into the same resource group that contains your storage account and Log Analytics workspace for operational event logging. If you didn't set up operational event logging, first follow the guidance in [Configure and query operation event logging for Azure Cloud HSM](tutorial-operation-event-logging.md).
39+
40+
Verify that your targeted resource group exists:
41+
42+
```azurepowershell
43+
az group show --name "<resource-group>" --query "{name:name, location:location}" --output table
44+
```
45+
46+
## Create an Event Hubs namespace
47+
48+
The namespace is the container that holds one or more event hubs. Use the **Standard** tier, which is required for diagnostic settings integration:
49+
50+
```azurepowershell
51+
az eventhubs namespace create `
52+
--name "<eventhub-namespace>" `
53+
--resource-group "<resource-group>" `
54+
--location "<location>" `
55+
--sku Standard `
56+
--capacity 1 `
57+
--enable-auto-inflate false
58+
```
59+
60+
Key options:
61+
62+
- `--sku Standard`: The Basic tier doesn't support diagnostic settings as a destination.
63+
- `--capacity 1`: One throughput unit (1 MB/s ingress, 2 MB/s egress) is sufficient for HSM audit logs.
64+
- `--enable-auto-inflate false`: HSM log volume is low, so auto-inflate isn't necessary.
65+
66+
## Create an event hub inside the namespace
67+
68+
Create an event hub (topic) to receive the Cloud HSM logs:
69+
70+
```azurepowershell
71+
az eventhubs eventhub create `
72+
--name "cloudhsm-logs" `
73+
--namespace-name "<eventhub-namespace>" `
74+
--resource-group "<resource-group>" `
75+
--partition-count 2 `
76+
--retention-time-in-hours 168 `
77+
--cleanup-policy Delete
78+
```
79+
80+
Key options:
81+
82+
- `--partition-count 2`: Two partitions are sufficient for HSM audit log throughput.
83+
- `--retention-time-in-hours 168`: Keep messages for 7 days (168 hours, which is the maximum for Standard tier).
84+
- `--cleanup-policy Delete`: Delete messages after the retention period expires.
85+
86+
## Create a consumer group
87+
88+
Create a dedicated consumer group for downstream processing. Reserve the default `$Default` group for other uses:
89+
90+
```azurepowershell
91+
az eventhubs eventhub consumer-group create `
92+
--name "azure-cloud-hsm" `
93+
--namespace-name "<eventhub-namespace>" `
94+
--eventhub-name "cloudhsm-logs" `
95+
--resource-group "<resource-group>"
96+
```
97+
98+
## Create an authorization rule
99+
100+
Diagnostic settings need **Send** permission to push logs into the event hub. Create a shared access policy with only the required permission:
101+
102+
```azurepowershell
103+
az eventhubs namespace authorization-rule create `
104+
--name "DiagnosticSettingsSendRule" `
105+
--namespace-name "<eventhub-namespace>" `
106+
--resource-group "<resource-group>" `
107+
--rights Send
108+
```
109+
110+
> [!NOTE]
111+
> This rule grants only `Send` permission, not `Listen` or `Manage`. Follow the principle of least privilege. Your downstream consumers (such as Azure Functions or Stream Analytics) should use a separate rule with `Listen` permission.
112+
113+
## Get the authorization rule resource ID
114+
115+
Retrieve the authorization rule resource ID for use in the diagnostic setting:
116+
117+
```azurepowershell
118+
$authRuleId = az eventhubs namespace authorization-rule show `
119+
--name "DiagnosticSettingsSendRule" `
120+
--namespace-name "<eventhub-namespace>" `
121+
--resource-group "<resource-group>" `
122+
--query id --output tsv
123+
124+
Write-Host "Auth Rule ID: $authRuleId"
125+
```
126+
127+
Save this value for use in the next step.
128+
129+
## Update the diagnostic setting to add Event Hub
130+
131+
You have two options for adding Event Hub as a destination:
132+
133+
### Option A: Update the existing diagnostic setting (recommended)
134+
135+
This approach updates your existing diagnostic setting to add Event Hub while keeping Storage and Log Analytics:
136+
137+
```azurepowershell
138+
# Set your resource group variables
139+
$hsmResourceGroup = "<resource-group>"
140+
$logsResourceGroup = "<resource-group>"
141+
142+
# Find the HSM cluster name (auto-generated during deployment)
143+
$hsmClusterName = az resource list `
144+
--resource-group $hsmResourceGroup `
145+
--resource-type Microsoft.HardwareSecurityModules/cloudHsmClusters `
146+
--query "[0].name" --output tsv
147+
Write-Host "HSM Cluster: $hsmClusterName"
148+
149+
# Get the HSM cluster resource ID
150+
$hsmResourceId = az resource show `
151+
--resource-group $hsmResourceGroup `
152+
--resource-type Microsoft.HardwareSecurityModules/cloudHsmClusters `
153+
--name $hsmClusterName `
154+
--query id --output tsv
155+
156+
# Get your existing storage account ID
157+
$storageAccountId = az storage account list `
158+
--resource-group $logsResourceGroup `
159+
--query "[0].id" --output tsv
160+
161+
# Get your existing Log Analytics workspace ID
162+
$workspaceId = az monitor log-analytics workspace list `
163+
--resource-group $logsResourceGroup `
164+
--query "[0].id" --output tsv
165+
166+
# Get the Event Hub auth rule ID
167+
$authRuleId = az eventhubs namespace authorization-rule show `
168+
--name "DiagnosticSettingsSendRule" `
169+
--namespace-name "<eventhub-namespace>" `
170+
--resource-group $logsResourceGroup `
171+
--query id --output tsv
172+
173+
# Update the diagnostic setting with all three destinations
174+
az monitor diagnostic-settings create `
175+
--name "<diagnostic-setting-name>" `
176+
--resource $hsmResourceId `
177+
--storage-account $storageAccountId `
178+
--workspace $workspaceId `
179+
--event-hub "cloudhsm-logs" `
180+
--event-hub-rule $authRuleId `
181+
--logs '[{\"category\":\"HsmServiceOperations\",\"enabled\":true}]'
182+
```
183+
184+
> [!IMPORTANT]
185+
> The `az monitor diagnostic-settings create` command performs an upsert operation. If the name matches an existing setting, it replaces the setting entirely. You must include `--storage-account` and `--workspace` again, or those destinations are removed.
186+
187+
### Option B: Create a separate diagnostic setting for Event Hub only
188+
189+
If you prefer to keep your existing setting unchanged and add a second one:
190+
191+
```azurepowershell
192+
# Find the HSM cluster name (if you don't already have it from Option A)
193+
$hsmClusterName = az resource list `
194+
--resource-group "<resource-group>" `
195+
--resource-type Microsoft.HardwareSecurityModules/cloudHsmClusters `
196+
--query "[0].name" --output tsv
197+
198+
$hsmResourceId = az resource show `
199+
--resource-group "<resource-group>" `
200+
--resource-type Microsoft.HardwareSecurityModules/cloudHsmClusters `
201+
--name $hsmClusterName `
202+
--query id --output tsv
203+
204+
$authRuleId = az eventhubs namespace authorization-rule show `
205+
--name "DiagnosticSettingsSendRule" `
206+
--namespace-name "<eventhub-namespace>" `
207+
--resource-group "<resource-group>" `
208+
--query id --output tsv
209+
210+
az monitor diagnostic-settings create `
211+
--name "chsm-eventhub-diagnostic-setting" `
212+
--resource $hsmResourceId `
213+
--event-hub "cloudhsm-logs" `
214+
--event-hub-rule $authRuleId `
215+
--logs '[{\"category\":\"HsmServiceOperations\",\"enabled\":true}]'
216+
```
217+
218+
> [!NOTE]
219+
> Azure supports up to five diagnostic settings per resource. A second setting is valid and keeps concerns separated.
220+
221+
## Verify Event Hub is receiving messages
222+
223+
After you configure the diagnostic setting, verify that Event Hub is receiving Cloud HSM logs.
224+
225+
### Check the diagnostic setting in the portal
226+
227+
1. In the Azure portal, go to your Cloud HSM cluster.
228+
1. Under **Monitoring**, select **Diagnostic settings**.
229+
1. Confirm that Event Hub is listed as a destination.
230+
231+
### Check Event Hub metrics
232+
233+
Run the following command to check incoming messages over the last hour:
234+
235+
```azurepowershell
236+
# Get your subscription ID
237+
$subId = az account show --query id --output tsv
238+
239+
# Check incoming messages (last 1 hour)
240+
az monitor metrics list `
241+
--resource "/subscriptions/$subId/resourceGroups/<resource-group>/providers/Microsoft.EventHub/namespaces/<eventhub-namespace>" `
242+
--metric "SuccessfulRequests" `
243+
--interval PT1H `
244+
--output table
245+
```
246+
247+
### Peek at messages (optional)
248+
249+
If you want to read a few messages to confirm content, create a **Listen** rule:
250+
251+
```azurepowershell
252+
# Create a Listen rule for your consumer
253+
az eventhubs namespace authorization-rule create `
254+
--name "ConsumerListenRule" `
255+
--namespace-name "<eventhub-namespace>" `
256+
--resource-group "<resource-group>" `
257+
--rights Listen
258+
259+
# Get the connection string
260+
az eventhubs namespace authorization-rule keys list `
261+
--name "ConsumerListenRule" `
262+
--namespace-name "<eventhub-namespace>" `
263+
--resource-group "<resource-group>" `
264+
--query primaryConnectionString --output tsv
265+
```
266+
267+
You can use this connection string with Azure Event Hub Explorer, the VS Code Event Hub extension, or a Python script to peek at messages.
268+
269+
## Related content
270+
271+
- [Configure and query operation event logging for Azure Cloud HSM](tutorial-operation-event-logging.md)
272+
- [Azure Event Hubs documentation](/azure/event-hubs/event-hubs-about)
273+
- [Diagnostic settings in Azure Monitor](/azure/azure-monitor/essentials/diagnostic-settings)
274+
- [Azure Monitor diagnostic log schema](/azure/azure-monitor/essentials/resource-logs-schema)

articles/cloud-hsm/tutorial-operation-event-logging.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: keithp
55
manager: keithp
66
ms.service: azure-cloud-hsm
77
ms.topic: tutorial
8-
ms.date: 03/26/2026
8+
ms.date: 04/08/2026
99
ms.author: keithp
1010

1111
#Customer Intent: As an IT pro, I want to set up and use operation event logging for Azure Cloud HSM to help ensure security and compliance.
@@ -240,4 +240,5 @@ The following names are related to HSM operation events.
240240
## Related content
241241

242242
- [Azure Cloud HSM overview](overview.md)
243+
- [Tutorial: Configure Event Hub for Azure Cloud HSM](tutorial-configure-event-hub.md)
243244
- [Tutorial: Deploy Azure Cloud HSM](tutorial-deploy-cloud-hsm.md)

0 commit comments

Comments
 (0)