Edit

Create a data flow graph in Azure IoT Operations

A data flow graph is a composable processing pipeline that transforms data as it moves between sources and destinations. A standard data flow follows a fixed enrich, filter, map sequence. A data flow graph lets you chain transforms in any order, branch into parallel paths, and aggregate data over time windows.

This article walks through creating a data flow graph step by step. For an overview of data flow graphs and the available transforms, see Data flow graphs overview.

Data flow graphs currently support only MQTT, Kafka, and OpenTelemetry endpoints. They don't support other endpoint types such as Data Lake, Microsoft Fabric OneLake, Azure Data Explorer, and Local Storage.

Transforms use an expression language to compute values, test conditions, and reference fields. Expressions refer to inputs by position, not by name: the first input in the inputs list is $1, the second is $2, and so on. Built-in functions such as cToF convert and manipulate those values.

For the complete list of operators, functions, data types, and metadata fields, see the Expressions reference.

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
    
  • Azure IoT Operations version 1.2 or later.

  • A data flow profile. You can use the default profile.

  • A data flow endpoint for your source and destination. The default MQTT broker endpoint works for getting started.

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 GRAPH_NAME and PROFILE environment variables for the data flow graph and profile names. Set each one before you run the related commands.

Create a data flow graph

A data flow graph contains three types of elements: sources that bring data in, transforms that process it, and destinations that send it out. Connect them in the order you want data to flow.

  1. In the operations experience, go to your Azure IoT Operations instance.

  2. Select Data flow graph > Create data flow graph.

    Screenshot of operations experience showing data flow graph.

  3. Enter a name for the data flow graph and select a data flow profile. The default profile is selected by default.

    Screenshot of the operations experience create dialog showing the name field and profile dropdown.

  4. Build your pipeline by adding elements to the canvas:

    1. Add a source: Select the source endpoint and configure the topics to subscribe to for incoming messages.

      Screenshot of the operations experience source configuration panel showing endpoint dropdown and topic input.

    2. Add transforms: Select one or more transforms to process the data. Available transforms include map, filter, branch, concatenate, window, and throttle. For details on each transform type, see Data flow graphs overview.

      Screenshot of the operations experience transform selection menu showing available transform types.

      Screenshot of the operations experience showing a branch transform configuration example.

    3. Add a destination: Select the destination endpoint and configure the topic or path to send processed data to.

      Screenshot of the operations experience showing a destination example.

  5. Connect the elements in the order you want data to flow.

    Screenshot of the operations experience canvas showing a connected source, transform, and destination pipeline.

  6. Select Save to deploy the data flow graph.

Configure the source

The source defines where data enters the pipeline. Specify an endpoint reference and one or more topics.

In the data flow graph editor, select the source element and configure:

Setting Description
Endpoint The data flow endpoint to use. Select default for the local MQTT broker.
Topics One or more topics to subscribe to for incoming messages.

Add transforms

Transforms process data between the source and destination. Each transform references a built-in artifact and has configuration rules.

The available built-in transforms are:

Transform Artifact Description
Map azureiotoperations/graph-dataflow-map:1.0.0 Rename, restructure, compute, and copy fields.
Filter azureiotoperations/graph-dataflow-filter:1.0.0 Drop messages that match a condition.
Branch azureiotoperations/graph-dataflow-branch:1.0.0 Route each message to a true or false path based on a condition.
Concatenate azureiotoperations/graph-dataflow-concatenate:1.0.0 Merge two or more paths back into one.
Window azureiotoperations/graph-dataflow-window:1.0.0 Collect messages over a time interval, then aggregate.
Throttle azureiotoperations/graph-dataflow-throttle:1.0.0 Limit the message rate per MQTT topic pattern.

For more information on enriching messages with external data, see Enrich with external data.

In the data flow graph editor, select Add transform and choose the transform type. Configure the rules in the visual editor.

Chain multiple transforms

Chain any number of transforms. Connect them in the nodeConnections section in the order you want data to flow:

Drag connections between transforms on the canvas to define the processing order.

Configure the destination

The destination defines where processed data goes. Specify an endpoint reference and a topic or path.

Select the destination element and configure:

Setting Description
Endpoint The data flow endpoint to send data to.
Topic The topic or path to publish processed data to.

For dynamic topic routing based on message content, see Route messages to different topics.

Verify the data flow graph is working

After you deploy a data flow graph, verify it's running:

In the operations experience, select your data flow graph to view its status. A healthy graph shows a Running state.