You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -44,51 +44,103 @@ Use the commands in the following sections to set up the resources that you want
44
44
45
45
### Create a storage account to store HSM logs
46
46
47
-
To create a storage account for storing HSM logs, you first need to create a resource group. You also need to create the storage account within that resource group. Use the following commands to create all these items:
47
+
To create a storage account for storing HSM logs, you first need to create a resource group. You also need to create the storage account within that resource group.
48
48
49
-
```bash
50
-
az group create --name <resource-group> --location <location>
To create a Log Analytics workspace for storing and analyzing HSM logs, use the following command:
79
+
To create a Log Analytics workspace for storing and analyzing HSM logs, use the following command.
80
+
81
+
# [Azure CLI](#tab/azure-cli)
57
82
58
-
```bash
59
-
az monitor log-analytics workspace create --resource-group <resource-group> --workspace-name <workspace-name>
83
+
```azurecli
84
+
az monitor log-analytics workspace create \
85
+
--resource-group "<resource-group>" \
86
+
--workspace-name "<workspace-name>"
60
87
```
61
88
89
+
# [Azure PowerShell](#tab/azure-powershell)
90
+
91
+
```azurepowershell
92
+
New-AzOperationalInsightsWorkspace `
93
+
-ResourceGroupName "<resource-group>" `
94
+
-Name "<workspace-name>" `
95
+
-Location "<location>"
96
+
```
97
+
98
+
---
99
+
62
100
For more information about creating a Log Analytics workspace for Azure Monitor, see [Create a Log Analytics workspace](/azure/azure-monitor/logs/quick-create-workspace?tabs=azure-cli).
63
101
64
-
### Enable diagnostic settings by using the Azure CLI or Azure PowerShell
102
+
### Enable diagnostic settings
65
103
66
-
To set variables and run the command to enable diagnostic settings for Azure Cloud HSM operation event logging, use the following code. Replace the placeholders for `SubscriptionId`, `ResourceGroupName`, `HSMName`, `StorageAccountName`, and `WorkspaceName` with the appropriate values for your environment.
104
+
To enable diagnostic settings for Azure Cloud HSM operation event logging, use the following code. Replace the placeholders with the appropriate values for your environment.
After you create the diagnostic setting, the logs start flowing in one to two minutes.
@@ -97,33 +149,59 @@ You can query Cloud HSM operation event logs from the Azure portal via the Log A
97
149
98
150
:::image type="content" source="./media/operation-event-logs-portal.png" lightbox="./media/operation-event-logs-portal.png" alt-text="Screenshot of Azure Cloud HSM operation event logs in the Azure portal.":::
99
151
100
-
You can also query Cloud HSM operation event logs by using the Azure CLI and Azure PowerShell. In this example, you update `ResourceGroupName` and `WorkspaceName`:
152
+
You can also query Cloud HSM operation event logs by using the Azure CLI or Azure PowerShell.
153
+
154
+
# [Azure CLI](#tab/azure-cli)
155
+
156
+
```azurecli
157
+
workspaceId=$(az monitor log-analytics workspace show \
158
+
--resource-group "<resource-group>" \
159
+
--workspace-name "<workspace-name>" \
160
+
--query customerId --output tsv)
161
+
162
+
az monitor log-analytics query \
163
+
--workspace $workspaceId \
164
+
--analytics-query "CloudHsmServiceOperationAuditLogs | take 10"
165
+
```
166
+
167
+
# [Azure PowerShell](#tab/azure-powershell)
101
168
102
-
```bash
103
-
$workspaceId = az monitor log-analytics workspace show --resource-group <resource-group> --workspace-name <workspace-name> --query customerId -o tsv
104
-
az monitor log-analytics query -w $workspaceId --analytics-query "CloudHsmServiceOperationAuditLogs | take 10"
169
+
```azurepowershell
170
+
$workspace = Get-AzOperationalInsightsWorkspace `
171
+
-ResourceGroupName "<resource-group>" `
172
+
-Name "<workspace-name>"
173
+
174
+
Invoke-AzOperationalInsightsQuery `
175
+
-WorkspaceId $workspace.CustomerId `
176
+
-Query "CloudHsmServiceOperationAuditLogs | take 10"
105
177
```
106
178
179
+
---
180
+
107
181
:::image type="content" source="./media/operation-event-logs-cli.png" lightbox="./media/operation-event-logs-cli.png" alt-text="Screenshot of Azure Cloud HSM operation event logs in the command-line interface.":::
108
182
109
-
####Registration error
183
+
### Registration error
110
184
111
185
If you get the error message "`<subscription>` is not registered to use microsoft.insights," your Azure subscription is not registered to use the `Microsoft.Insights` resource provider. To resolve this problem, you need to register with the `Microsoft.Insights` provider in your subscription.
112
186
113
-
To register `Microsoft.Insights` by using the Azure CLI, run the following command:
187
+
# [Azure CLI](#tab/azure-cli)
114
188
115
-
```bash
189
+
```azurecli
116
190
az provider register --namespace Microsoft.Insights
191
+
117
192
az provider show --namespace Microsoft.Insights --query "registrationState" --output table
118
193
```
119
194
120
-
To register `Microsoft.Insights` by using Azure PowerShell, run the following command:
After you run the command, ensure that the resource provider is registered. If it's still registering, you might need to wait a few moments and check again.
128
206
129
207
## Query operation event logs
@@ -134,7 +212,7 @@ For details on other operations that can be queried, refer to the [comprehensive
134
212
135
213
### Login and session events
136
214
137
-
```bash
215
+
```kusto
138
216
// Find login and session events
139
217
CloudHsmServiceOperationAuditLogs
140
218
| where OperationName in ("CN_LOGIN", "CN_AUTHORIZE_SESSION")
0 commit comments