Skip to content

Commit 115e26a

Browse files
committed
work in progress
1 parent c75c5fa commit 115e26a

File tree

9 files changed

+15
-18
lines changed

9 files changed

+15
-18
lines changed

articles/api-management/api-management-howto-log-event-hubs.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ This article describes how to log API Management events using Azure Event Hubs.
2525
2626
## Configure access to the event hub
2727

28-
To log events to the event hub, you need credentials to enable access from API Management. API Management supports two access mechanisms: an Event Hubs connection string, or an API Management managed identity.
28+
To log events to the event hub, you need to configure credentials for access from API Management. API Management supports two access mechanisms:
29+
30+
* An event hub connection string
31+
* A managed identity for your API Management instance.
2932

3033
### Configure event hub connection string
3134

32-
To create an Event Hubs connection string, see [Get an Event Hubs connection string](../event-hubs/event-hubs-get-connection-string.md). You can get a connection string to the namespace or the specific event hub you use for logging from API Management
35+
To create an Event Hubs connection string, see [Get an Event Hubs connection string](../event-hubs/event-hubs-get-connection-string.md).
36+
37+
* You can use a connection string for the Event Hubs namespace or for the specific event hub you use for logging from API Management.
38+
* The shared access policy for the connection string must enable at least **Send** permissions.
3339

3440
### Configure API Management managed identity
3541

@@ -40,25 +46,25 @@ To create an Event Hubs connection string, see [Get an Event Hubs connection str
4046

4147
* If you enable a user-assigned managed identity, take note of the identity's **Client ID**.
4248

43-
1. Assign the identity the **Azure Event Hubs Data Owner** role, scoped to the Event Hubs namespace or to the event hub used for logging. To assign the role, use the [Azure portal](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md) or other Azure tools.
44-
49+
1. Assign the identity the **Azure Event Hubs Data sender** role, scoped to the Event Hubs namespace or to the event hub used for logging. To assign the role, use the [Azure portal](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md) or other Azure tools.
4550

4651
## Create an API Management logger
47-
Now that you have an event hub, the next step is to configure a [Logger](/rest/api/apimanagement/current-ga/logger) in your API Management service so that it can log events to the event hub.
52+
The next step is to configure a [logger](/rest/api/apimanagement/current-ga/logger) in your API Management service so that it can log events to the event hub.
4853

49-
API Management loggers can be configured using the [API Management REST API](/rest/api/apimanagement/current-ga/logger/create-or-update) directly or tools including [Azure PowerShell](/powershell/module/az.apimanagement/new-azapimanagementlogger), a Bicep template, or an Azure Resource Management template.
54+
You can create and manage API Management loggers using the [API Management REST API](/rest/api/apimanagement/current-ga/logger/create-or-update) directly or using tools including [Azure PowerShell](/powershell/module/az.apimanagement/new-azapimanagementlogger), a Bicep template, or an Azure Resource Management template.
5055

5156
### Logger with connection string credentials
5257

5358
#### [PowerShell](#tab/PowerShell)
5459

55-
The following example uses the [New-AzApiManagementLogger](/powershell/module/az.apimanagement/new-azapimanagementlogger) cmdlet to create a logger to an event hub by specifying a connection string.
60+
The following example uses the [New-AzApiManagementLogger](/powershell/module/az.apimanagement/new-azapimanagementlogger) cmdlet to create a logger to an event hub by configuring a connection string.
5661

5762
```powershell
5863
# API Management service-specific details
5964
$apimServiceName = "apim-hello-world"
6065
$resourceGroupName = "myResourceGroup"
6166
67+
# Create logger
6268
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $apimServiceName
6369
New-AzApiManagementLogger -Context $context -LoggerId "ContosoLogger1" -Name "ApimEventHub" -ConnectionString "Endpoint=sb://ContosoEventHubs.servicebus.windows.net/;SharedAccessKeyName=SendKey;SharedAccessKey=<key>" -Description "Event hub logger with connection string"
6470
```
@@ -118,7 +124,7 @@ Include the following JSON snippet in your Azure Resource Manager template.
118124

119125
## Configure log-to-eventhub policy
120126

121-
Once your logger is configured in API Management, you can configure your [log-to-eventhub](api-management-advanced-policies.md#log-to-event-hub) policy to log the desired events. The `log-to-eventhub` policy can be used in either the inbound policy section or the outbound policy section.
127+
Once your logger is configured in API Management, you can configure your [log-to-eventhub](api-management-advanced-policies.md#log-to-eventhub) policy to log the desired events. For example, use the `log-to-eventhub` policy in the inbound policy section to log requests, or in the outbound policy section to log responses.
122128

123129
1. Browse to your API Management instance.
124130
1. Select **APIs**, and then select the API to which you want to add the policy. In this example, we're adding a policy to the **Echo API** in the **Unlimited** product.
@@ -156,7 +162,7 @@ You can preview the log in Event Hubs by using [Azure Stream Analytics queries](
156162

157163
1. In the Azure portal, browse to the event hub that the logger sends events to.
158164
2. Under **Features**, select the **Process data** tab.
159-
3. On the **Enable real time insights from events** card, select **Explore**.
165+
3. On the **Enable real time insights from events** card, select **Start**.
160166
4. You should be able to preview the log on the **Input preview** tab. If the data shown isn't current, select **Refresh** to see the latest events.
161167

162168
## Next steps
@@ -169,12 +175,3 @@ You can preview the log in Event Hubs by using [Azure Stream Analytics queries](
169175
* [log-to-eventhub policy reference](./api-management-advanced-policies.md#log-to-eventhub)
170176
* [Monitor your APIs with Azure API Management, Event Hubs, and Moesif](api-management-log-to-eventhub-sample.md)
171177
* Learn more about [integration with Azure Application Insights](api-management-howto-app-insights.md)
172-
173-
[publisher-portal]: ./media/api-management-howto-log-event-hubs/publisher-portal.png
174-
[create-event-hub]: ./media/api-management-howto-log-event-hubs/create-event-hub.png
175-
[event-hub-connection-string]: ./media/api-management-howto-log-event-hubs/event-hub-connection-string.png
176-
[event-hub-dashboard]: ./media/api-management-howto-log-event-hubs/event-hub-dashboard.png
177-
[receiving-policy]: ./media/api-management-howto-log-event-hubs/receiving-policy.png
178-
[sending-policy]: ./media/api-management-howto-log-event-hubs/sending-policy.png
179-
[event-hub-policy]: ./media/api-management-howto-log-event-hubs/event-hub-policy.png
180-
[add-policy]: ./media/api-management-howto-log-event-hubs/add-policy.png
Binary file not shown.

0 commit comments

Comments
 (0)