# Sending data to Azure Event Hubs

{% hint style="warning" %}
This documentation references external sources.

Nexthink does not control the accuracy of third-party documentation or external updates that can result in inconsistencies.

Report any errors or inconsistencies to [Nexthink Support](https://support.nexthink.com/).
{% endhint %}

This document outlines how to send data to Azure Event Hubs using Nexthink Webhooks.

## Prerequisites

Before you start, ensure you have the following:

* Azure account
* Postman account
* Nexthink license

## In Azure portal

### Create a resource group

A resource group is a logical container for Azure resources.

1. Sign in to the [Azure portal](https://portal.azure.com).
2. Select **Resource groups** from the main menu, and click **Create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-1dba45b97f263bac501e90a7c94677e3935b98eb%2FResourcesGroup.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Select the relevant subscription and provide a unique name for the resource group.
3. From the **Region group** drop-down, select the relevant region group, and click **Review + Create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-46ae29af40c7d9009ab2ef8534e3f9975a8f6275%2Fimage3.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Review the details, and click **Create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-852021791b7d6e2c39befb4d2e3e2e241ee1a66a%2Fimage4.png?alt=media" alt=""><figcaption></figcaption></figure>

### Create an Event Hubs namespace

Before creating an Event Hub, the system requires an Event Hubs namespace.

1. In the Azure portal, select **All services**.
2. Type **Event Hubs into the search field.**
3. Hover over **Event Hubs** and click the star to add Event Hubs to the **Favorites** list.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-9944520e612d20c5341f2dd0603c8bdb9a959382%2Fimage6.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Under the **Favorites** tab, select **Event Hubs** and click **Create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-19d9a45cc36589d522f50861bf58374c32860220%2Fimage7.png?alt=media" alt=""><figcaption></figcaption></figure>

5. From the drop-down menu in the search field, select the relevant **Subscription** and **Resource group**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-2c95b4ce41a52d2e7cb4997b02e3a3a4005efe98%2FAZURE-0122.png?alt=media" alt=""><figcaption></figcaption></figure>

6. Once the namespace is deployed, navigate to the **Namespace page**.

* On the **Deployment** page, select **Go to resource** to navigate to the page for your namespace.
* Confirm that you see an **Event Hubs Namespace** page similar to the following example:

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-84e2843f469dabc1cc14be0fc03562128c3d435e%2FAZURE-01222.png?alt=media" alt=""><figcaption></figcaption></figure>

### Create an Event Hub

1. On the Event Hubs page, select **Overview** > **+** **Event Hub**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-fd6fa38a523a0946fd586f9bd88440fcdf835455%2FAZURE-012222.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Enter a name for the Event Hub and click **Review + create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-63b1caf695ef19cd8b3584a28d6a8df5d7f69812%2Fimage12.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Review the Event Hub information, and click **Create**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-89a9bda5e3c051ce4158b08c8fb6efacc6d5dbc0%2FCreateEventHub-%20001w.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Under the **Entities** tab, select **Event Hubs** to review a list of Event Hubs.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-765a2601d2f38fb64710ddfb5fef61b3f6f0c3bc%2FAZURE-01111.png?alt=media" alt=""><figcaption></figcaption></figure>

### Register the application with Microsoft Entra ID

To authenticate against Azure, register the application using Microsoft Entra ID (formerly Azure AD).

1. Sign in to the [Azure portal](https://portal.azure.com/).
2. Enter **Microsoft Entra ID** in the search field and select it from the drop-down list.
3. Select **App registrations** from the main menu.
4. Click on **+ New registration**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-ea30b313201ec3d5c239eb84f3251b578f67da41%2Fimage15.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Enter a name for the application and click **Register**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-19d900d92bbbdfcf5a14437f30359903c8975ac8%2Fimage16.png?alt=media" alt=""><figcaption></figcaption></figure>

6. On the **Overview** page, copy the **Application (client) ID** and **Directory (tenant) ID**. Use these values to get a token from Microsoft Entra ID.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-147efe612bef7f9806645e49072a44a247c1d89c%2FEventHubs-001234.png?alt=media" alt=""><figcaption></figcaption></figure>

7. Select **Certificates & secrets** in the main menu, and click **+ New client secret**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-4c891ac1d4cd2cdac0663464b36ccf24eaddd2a9%2Fimage18.png?alt=media" alt=""><figcaption></figcaption></figure>

8. In the **Description** field, add a description of the client secre&#x74;**.**
9. From the **Expires** drop-down, select the expiry period for the application.
10. Click **Add**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-1b42efba933ade14099d80c58de41bedbb17cf07%2FEventHubs-0012345.png?alt=media" alt=""><figcaption></figcaption></figure>

11. Under the **Client secrets** tab, click the copy icon next to the **Value** and **Secret ID** fields to get a token from Microsoft Entra ID.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-6b0e4909a28211135917f599cdb78d6c2cd6a05e%2FAZURE-0163.png?alt=media" alt=""><figcaption></figcaption></figure>

### Add the application to the Event Hubs data sender

Assign your application to the **Azure Event Hubs Data Sender** role for access.

1. Select **Access control (IAM),** and click **Add role assignment**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-add209e8945d5e38dbb9679d667609ba158fb3ea%2Fimage21.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Select **Azure Event Hubs Data Sender** to role and the application under **Members**.
3. Click **Review + assign**.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-ecc32c360bc040630437a8c42c2f0299b22c38f9%2FAZURE-0162.png?alt=media" alt=""><figcaption></figcaption></figure>

## In Postman

Use Postman to get a Microsoft Entra token. Authenticate the webhook requests using either:

* Bearer token
* OAuth 2.0

### Bearer token

1. Sign in to Postman and create a new request.
2. Set the method to **GET** and enter the following URL:\
   `https://login.microsoftonline.com/<TENANT_ID>/oauth2/v2.0/token`

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-7e1b7dbb5f535c80e2553acbd31255303b454292%2FPostman-001%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

3. Under the **Headers** tab, add the **Content-Type** key `application/x-www-form-urlencoded` for the value.
4. Under the **Body** tab, select **form-data** and add the following key-value pairs:
   * `grant_type`: `client_credentials`
   * `client_id`: Paste the client ID from earlier.
   * `client_secret`: Paste the client secret.
   * `resource`: `https://eventhubs.azure.net`
5. Click **Send** and save the token. This returns the **200** status code.

### OAuth 2.0

1. In Postman, open a new tab.
2. Select **POST** for the method.
3. Enter the URL in the following format: `https://<EVENT HUBS NAMESPACE NAME>.servicebus.windows.net/<QUEUE NAME>/messages`. Replace:
   * `<EVENT HUBS NAMESPACE NAME>` with the name of the Event Hubs namespace.
   * `<QUEUE NAME>` with the name of the queue—the queue name will be the Event Hub name.
4. Under the **Body** tab, select **raw** for the data type and add the message you want to send in the request.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-0bb474f923ff6f618beb326857a55b497a8d8187%2Fimage28.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Select **Send**. This returns the **201** status code, as shown in the image.

The message is posted on the **Event Hubs Namespace** page.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-ce22199921932403f79dee20d49ea8aabd80c2ea%2FAZURE-0161.png?alt=media" alt=""><figcaption></figcaption></figure>

## In Nexthink

### Create webhook credentials

From the Nexthink web interface:

1. Go to **Administration > Connector Credentials** in the main menu.
2. Click **New Credential** and fill out the following details:
   * **Name:** Name of the webhook.
   * **Description:** Meaningful description of the action performed by the webhook.
   * **Protocol**: Select **Hypertext Transfer Protocol Secure (HTTPS)**. Refer to the [Connector credentials for HTTPS](https://docs.nexthink.com/platform/integrations/outbound-connectors/connector-credentials) section in the [Connector credentials](https://docs.nexthink.com/platform/latest/webhooks-manage-credentials) documentation.
   * **URL for HTTPS protocol**

     Enter the URL of the third-party tool in the following format: `https://<EVENT HUB NAMESPACE>.servicebus.windows.net/`
   * **Authorization:** Choose the authorization type from the drop-down list.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-2eb36281c77cbbe532fcf73d296e9806643d8f6e%2FNXT-01%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

3. Save the newly created credential and return to configure a webhook.

### Create a webhook in Nexthink

From the Nexthink web interface:

1. Go to **Administration > Outbound Connectors > Webhooks**.
2. Click **New Webhook**, and complete the form:
   * **Name**: Enter a name for the webhook.
   * **NQL Condition**: Configure an NQL query that defines the condition to trigger the webhook.
   * **Request Method**: POST.
   * **Resource**: URL of the Event Hub in the format:\
     `<EVENT HUB NAME>/messages`
   * **Payload**: JSON payload to be sent to the Event Hub.
3. Click **Send Test** to validate the configuration.
4. Once the configuration is validated, click **Save webhook**.

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nexthink.com/platform/configuring_nexthink/bringing-data-into-your-nexthink-instance/integrating-nexthink-with-third-party-tools/outbound-connectors/webhooks/webhook-use-cases-setup/sending-data-to-azure-event-hubs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
