Edit

Configure data flow endpoints for Azure Data Explorer

To send data to Azure Data Explorer in Azure IoT Operations, you can configure a data flow endpoint. This configuration allows you to specify the destination endpoint, authentication method, table, and other settings.

Prerequisites

  • The Azure CLI installed on your development machine. Check Available Azure CLI extensions for the minimum required version to use the azure-iot-ops extension. Use az --version to check your version and az upgrade to update if necessary. For more information, see Install the Azure CLI.

  • The Azure IoT Operations extension for the Azure CLI. Use the following command to add the extension or update it to the latest version:

    az extension add --upgrade --name azure-iot-ops
    

The Azure CLI examples in this article use environment variables so that you can set each value once and then copy and paste the commands as-is. If you're using the Azure IoT Operations Codespaces environment from the quickstart, these variables are already set for you and you can skip this step. Otherwise, set the following environment variables in your shell before you run the commands.

The following scripts set the most commonly used environment variables:

Environment variable Description
SUBSCRIPTION_ID The ID of the subscription that contains your Azure IoT Operations instance.
RESOURCE_GROUP The name of the resource group that contains your Azure IoT Operations instance.
AIO_INSTANCE_NAME The name of your Azure IoT Operations instance. To list your instances, run az iot ops list -o table.
CLUSTER_NAME The name of the Azure Arc-enabled Kubernetes cluster that hosts your instance.
LOCATION The Azure region to use for new resources, for example eastus.
SUBSCRIPTION_ID=<subscription-id>
RESOURCE_GROUP=<resource-group-name>
AIO_INSTANCE_NAME=<instance-name>
CLUSTER_NAME=<cluster-name>
LOCATION=<region>

You only need to set the variables that this article uses. This article might use additional environment variables for resource names that you choose. The article explains how to set them where they're introduced.

This article also uses the following environment variables for values that you choose: ENDPOINT, ADX_CLUSTER_NAME, ADX_DATABASE_NAME, CLIENT_ID, TENANT_ID, and SCOPE. Set each one before you run the related commands.

Create an Azure Data Explorer database

  1. In the Azure portal, create a database in your Azure Data Explorer full cluster.

  2. Create a table in your database for the data. You can use the Azure portal and create columns manually, or you can use KQL in the query tab. For example, to create a table for sample thermostat data, run the following command:

    .create table thermostat (
        externalAssetId: string,
        assetName: string,
        CurrentTemperature: real,
        Pressure: real,
        MqttTopic: string,
        Timestamp: datetime
    )
    
  3. Enable streaming ingestion on your table and database. In the query tab, run the following command, substituting <DATABASE_NAME> with your database name:

    .alter database ['<DATABASE_NAME>'] policy streamingingestion enable
    

    Alternatively, enable streaming ingestion on the entire cluster. See Enable streaming ingestion on an existing cluster.

Assign permission to managed identity

To configure a data flow endpoint for Azure Data Explorer, we recommend using either a user-assigned or system-assigned managed identity. This approach is secure and eliminates the need for managing credentials manually.

Important

If you're using a data flow graph and a user-assigned managed identity, make sure to assign the identity with the --usage wasm-graph flag when you run the az iot ops identity assign command. This ensures that the identity has the correct permissions for data flow graphs.

After the Azure Data Explorer database is created, you need to assign a role to the Azure IoT Operations managed identity that grants permission to write to the database.

If using system-assigned managed identity, in Azure portal, go to your Azure IoT Operations instance and select Overview. Copy the name of the extension listed after Azure IoT Operations Arc extension. For example, azure-iot-operations-xxxx7. Your system-assigned managed identity can be found using the same name of the Azure IoT Operations Arc extension.

  1. In your Azure Data Explorer database (not cluster), under Overview select Permissions > Add and then select Ingestor as the role. This gives the managed identity the necessary permissions to write to the Azure Data Explorer database. To learn more, see Role-based access control.
  2. Search for the name of your user-assigned managed identity set up for cloud connections or the system-assigned managed identity. For example, azure-iot-operations-xxxx7.
  3. Then, select Select.

Create data flow endpoint for Azure Data Explorer

  1. In the operations experience, select the Data flow endpoints tab.

  2. Under Create new data flow endpoint, select Azure Data Explorer > New.

    Screenshot using operations experience to create an Azure Data Explorer data flow endpoint.

  3. Enter the following settings for the endpoint:

    Setting Description
    Name The name of the data flow endpoint.
    Host The hostname of the Azure Data Explorer endpoint in the format <cluster>.<region>.kusto.windows.net.
    Authentication method The method used for authentication. Choose System assigned managed identity or User assigned managed identity.
    Client ID The client ID of the user-assigned managed identity. Required if using User assigned managed identity.
    Tenant ID The tenant ID of the user-assigned managed identity. Required if using User assigned managed identity.
  4. Select Apply to provision the endpoint.

Available authentication methods

The following authentication methods are available for Azure Data Explorer endpoints.

System-assigned managed identity

Before you configure the data flow endpoint, assign a role to the Azure IoT Operations managed identity that grants permission to write to the Azure Data Explorer database:

  1. In Azure portal, go to your Azure IoT Operations instance and select Overview.
  2. Copy the name of the extension listed after Azure IoT Operations Arc extension. For example, azure-iot-operations-xxxx7.
  3. Go to Azure Data Explorer database (not cluster), under Overview select Permissions > Add and then select an appropriate role.
  4. Search for the name of your system-assigned managed identity. For example, azure-iot-operations-xxxx7.
  5. Select Select.

Then, configure the data flow endpoint with system-assigned managed identity settings.

In the operations experience data flow endpoint settings page, select the Basic tab then choose Authentication method > System assigned managed identity.

If you need to override the system-assigned managed identity audience, you can specify the audience setting.

In most cases, you don't need to specify other settings. This configuration creates a managed identity with the default audience https://api.kusto.windows.net.

User-assigned managed identity

To use user-assigned managed identity for authentication, you must first deploy Azure IoT Operations with secure settings enabled. Then you need to set up a user-assigned managed identity for cloud connections. To learn more, see Enable secure settings in Azure IoT Operations deployment.

Before you configure the data flow endpoint, assign a role to the user-assigned managed identity that grants permission to write to the Azure Data Explorer database:

  1. In Azure portal, go to Azure Data Explorer database (not cluster), under Overview select Permissions > Add and then select an appropriate role.
  2. Search for the name of your user-assigned managed identity.
  3. Select Select.

Then, configure the data flow endpoint with user-assigned managed identity settings.

In the operations experience data flow endpoint settings page, select the Basic tab then choose Authentication method > User assigned managed identity.

Enter the user assigned managed identity client ID and tenant ID in the appropriate fields.

Here, the scope is optional and defaults to https://api.kusto.windows.net/.default. If you need to override the default scope, specify the scope setting via Bicep or Kubernetes.

Advanced settings

You can set advanced settings for the Azure Data Explorer endpoint, such as the batching latency and message count.

Use the batching settings to configure the maximum number of messages and the maximum latency before the messages are sent to the destination. This setting is useful when you want to optimize for network bandwidth and reduce the number of requests to the destination.

Field Description Required
latencySeconds The maximum number of seconds to wait before sending the messages to the destination. The default value is 60 seconds. No
maxMessages The maximum number of messages to send to the destination. The default value is 100000 messages. No

For example, to configure the maximum number of messages to 1000 and the maximum latency to 100 seconds, use the following settings:

In the operations experience, select the Advanced tab for the data flow endpoint.

Screenshot using operations experience to set Azure Data Explorer advanced settings.

Next steps

To learn more about data flows, see Create a data flow.