Edit

Configure the connector for OPC UA

OPC UA servers are software applications that communicate with assets. OPC UA servers expose OPC UA data points that represent data points. OPC UA data points provide real-time or historical data about the status, performance, quality, or condition of assets.

An asset in Azure IoT Operations is a logical entity that you create to represent a physical asset or device. An Azure IoT Operations asset can have custom properties, data points, streams, and events that describe its behavior and characteristics. An asset is associated with one or more devices. Azure IoT Operations stores asset definitions in the Azure Device Registry.

A device in Azure IoT Operations is a logical entity that defines the connections to physical assets or devices. Without a device, data can't flow from a physical device or asset to the MQTT broker. When you configure a device and asset, a connection is established to the physical asset or device and data point values, events, and streams arrive in Azure IoT Operations instance. A device has one or more inbound endpoints. Azure IoT Operations stores device definitions in the Azure Device Registry.

This article describes how to use the operations experience, Azure CLI, and Bicep to:

  • Define the devices that connect OPC UA servers to your Azure IoT Operations instance.
  • Add assets, and define their data points and events to enable data flow from OPC UA servers to the MQTT broker.

These assets, data points, and events map inbound data from OPC UA servers to friendly names that you can use in the MQTT broker and data flows.

For endpoint session modes and connector redundancy, see Configure OPC UA sessions and high availability. For dynamic node resolution, key frames, and event filters, see Configure advanced OPC UA data collection.

The connector can use anonymous, username password, or X.509certificate user authentication when it connects to an OPC UA server.

Note

This user authentication is separate from the certificate-based application authentication that's used to establish a secure channel between the connector for OPC UA and the OPC UA server. To learn more, see Understand the OPC UA certificates infrastructure.

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 connector for OPC UA is enabled on your Azure IoT Operations instance.

To sign in to the operations experience web UI, you need a Microsoft Entra ID account with at least contributor permissions for the resource group that contains your Kubernetes - Azure Arc instance. You can't sign in with a Microsoft account (MSA). For more information, see Troubleshoot access to the operations experience web UI.

  • Your IT administrator configures the OPC UA connector template for your Azure IoT Operations instance in the Azure portal or by using the Azure CLI.
  • An OPC UA server that you can reach from your Azure IoT Operations cluster. If you don't have an OPC UA server, use the OPC PLC simulator from the Azure IoT Operations samples repository.

Create a device

An Azure IoT Operations deployment can include a sample OPC PLC simulator. To create a device that uses the OPC PLC simulator:

  1. Select devices and then Create device:

    Screenshot that shows the devices page in the operations experience.

    Tip

    Use the filter box to search for devices.

  2. On the Basics page, enter a device name and select New on the Microsoft.OpcUa tile to add an endpoint for the device:

    Screenshot that shows how to create a device in the operations experience.

  3. Enter your endpoint information. For example, to use the OPC PLC simulator, enter the following values:

    Field Value
    Name opc-ua-connector-0
    Connector for OPC UA URL opc.tcp://opcplc-000000:50000
    User authentication Anonymous
  4. Select Next. On the Additional Info page enter any custom properties for the device.

  5. Select Next to review your device details. Then select Create.

This configuration deploys a new device resource called opc-ua-connector-bicep to the cluster with an inbound endpoint called opc-ua-connector-0.

When the OPC PLC simulator is running, data flows from the simulator, to the connector for OPC UA, and then to the MQTT broker.

Configure a device to use a username and password

The previous example uses the Anonymous authentication mode. This mode doesn't require a username or password.

To use the UsernamePassword authentication mode, complete the following steps:

In the operations experience, when you add the inbound endpoint and choose the Username password authentication mode, select Add reference to add the secret references for the username and password. The operations experience offers two options:

  • Create a new secret: uploads the value to Azure Key Vault and synchronizes it to the cluster as a synced secret.
  • Add from Azure Key Vault: synchronizes an existing Key Vault secret to the cluster.

The operations experience saves both the username and password references in a single synced secret resource on the cluster, and you give that synced secret a name.

To learn more, see Add and use secrets.

Configure a device to use an X.509 certificate

In the operations experience, when you add the inbound endpoint and choose the X509 certificate authentication mode, select Add reference to add the secret reference for the client certificate and private key. The operations experience offers two options:

  • Create a new secret: uploads the certificate and private key files to Azure Key Vault and synchronizes them to the cluster as a synced secret.
  • Add from Azure Key Vault: synchronizes existing Key Vault secrets to the cluster.

The operations experience saves the certificate and key references in a single synced secret resource on the cluster, and you give that synced secret a name.

To learn more, see Sync a client certificate and private key for mutual TLS.

Other security options

When you create the inbound endpoint, you can also select:

Option Type Description
Auto accept untrusted server certificate Yes/No Automatically accept untrusted server certificates
Security policy Dropdown Security policy used to establish secure channel with the OPC UA server
Security mode Dropdown Security mode used to communicate within secure channel with the OPC UA server

Add an asset, dataset, and data points

To add an asset in the operations experience, follow these steps:

  1. Select the Assets tab. Before you create any assets, you see the following screen:

    Screenshot that shows an empty Assets tab in the operations experience.

    Tip

    Use the filter box to search for assets.

  2. Select Create asset.

  3. On the asset details screen, enter the following asset information:

    • Inbound endpoint. Select your device inbound endpoint from the list.
    • Asset name
    • Description
  4. Configure the set of custom properties that you want to associate with the asset. You can accept the default list of properties or add your own. The following properties are available by default:

    • Manufacturer
    • Manufacturer URI
    • Model
    • Product code
    • Hardware version
    • Software version
    • Serial number
    • Documentation URI

    Screenshot that shows how to add asset details in the operations experience.

  5. Select Next to go to the Datasets page.

Add a dataset to an asset

A dataset defines where the connector sends the data it collects from a collection of data points. An OPC UA asset can have multiple datasets. To create a dataset:

  1. Select Create dataset.

  2. Enter the details for the dataset such as its name and destination. For OPC UA assets, the destination is an MQTT topic. For example:

    Screenshot that shows how to create a dataset in the operations experience.

    Use the Start instance field to specify the starting node for resolving relative browse paths for data points in the dataset. For more information, see Resolve dynamic nodes by using browse paths.

  3. Select Create and next to create the dataset.

Tip

Use the Manage default settings option to configure default dataset settings such as publishing interval, sampling interval, and queue size.

Add individual data points to a dataset

Important

The data point name _ErrorMessage is reserved and shouldn't be used.

Now you can define the data points associated with the dataset. To add OPC UA data points:

  1. Select Add data point.

  2. Enter your data point details:

    • Data source. This value is the node ID from the OPC UA server.
    • Data point name (Optional). This value is the friendly name that you want to use for the data point. If you don't specify a data point name, the node ID is used as the data point name.
    • Sampling interval (milliseconds). You can override the default value for this data point.
    • Queue size. You can override the default value for this data point.
    • Key frame count. By default, key frames are disabled. Use this setting to enable key frames and specify how frequently the connector generates key frames. For more information, see Configure key frames for state recovery.

    Screenshot that shows adding data points in the operations experience.

    The following table shows some example data point values that you can use with the built-in OPC PLC simulator:

    Data source Data point name
    ns=3;s=FastUInt10 Temperature
    ns=3;s=FastUInt100 Humidity

    Note

    If you're using relative browse paths to resolve dynamic nodes, the Data source field contains a relative browse path. For more information, see Resolve dynamic nodes by using browse paths.

  3. On the data points page, select Next to go to the Add events page.

Configure dataset triggering

Starting with Azure IoT Operations 2607, you can configure one data point to trigger publication of the other sampled data points in the same dataset. Dataset triggering is supported only for assets that reference a namespaced device endpoint. To learn about reporting modes, requirements, and fallback behavior, see Control dataset publishing with a triggering item.

The following examples configure a telemetry dataset with dataPoint-SlowUInt1 as the triggering item. The default Sampling reporting mode means that the trigger controls publication but its own value isn't included in the published output.

  1. In the operations experience, select Assets, and then open or create the my-triggered-asset asset. Select the opc-ua-connector-0 inbound endpoint on the namespaced device that you created previously.

  2. On the Datasets page, select or create the telemetry dataset. Set the destination topic to azure-iot-operations/data/my-triggered-asset, the publishing interval to 1000 milliseconds, and the sampling interval to 500 milliseconds.

  3. Add the following data points to the dataset. Data point names are case-sensitive.

    Data point name Data source
    dataPoint-SlowUInt1 nsu=http://microsoft.com/Opc/OpcPlc/;s=SlowUInt1
    dataPoint-FastUInt1 nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1
    dataPoint-FastUInt2 nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2
  4. In the dataset settings, set Triggering item to dataPoint-SlowUInt1 and Triggering item reporting mode to Sampling.

    Screenshot of Azure IoT Operations dataset settings with dataPoint-SlowUInt1 as the triggering item and Sampling as the reporting mode.

  5. Save the asset configuration.

To include the triggering data point in the published output, change triggeringItemReportingMode to Reporting. The triggeringItem value is case-sensitive and must match exactly one data point name in the same dataset.

Verify dataset triggering

  1. Subscribe to the dataset's destination MQTT topic. For an example, see Connector for OPC UA message format.

  2. Change either dataPoint-FastUInt1 or dataPoint-FastUInt2 without changing dataPoint-SlowUInt1. Verify that the connector samples the changed value but doesn't publish the dataset.

  3. Change dataPoint-SlowUInt1. Verify that the connector publishes the sampled fast data point values together.

  4. Review the asset status for trigger validation errors. If the status reports an error, inspect the connector logs. For information about viewing pod logs, see kubectl.

Troubleshoot dataset triggering

Symptom Resolution
The dataset publishes on every value change. Verify that triggeringItem is in the dataset's own datasetConfiguration and exactly matches one data point name. Check the connector logs for validation or trigger-link errors.
Triggering is unexpectedly disabled. Check the asset status for an Unprocessable telemetry.TriggeringItem error. Verify that the trigger name has exactly one match and that the dataset doesn't exceed subscription.maxItems.
The triggering data point is missing from the output. Set triggeringItemReportingMode to Reporting. In the default Sampling mode, the trigger controls publication but doesn't report its own value.

Add events and event groups

Add an event group to an asset

An event group defines where the connector sends the data it receives from a collection of events. An OPC UA asset can have multiple event groups. To create an event group:

  1. Select Create event group.

  2. Enter a name for the event group and any other required details:

    Screenshot that shows how to create an event group in the operations experience.

  3. Select Create and next to create the event group and go to the List of events for alerts page.

Add events to an event group

Now you can define the events associated with the event group. To add OPC UA events:

  1. Select Add event.

  2. Enter your event details:

    • Data source. This value is the event notifier from the OPC UA server.
    • Event name (Optional). This value is the friendly name that you want to use for the event. If you don't specify an event name, the event notifier is used as the event name.
    • Topic. The MQTT topic that you want the event to be published to.
    • Sampling interval (milliseconds). You can override the default value for this event.
    • Queue size. You can override the default value for this event.
    • Start instance. This value is the starting node for resolving relative browse paths for this event. This field is required if you use relative browse paths in the Data source field. For more information, see Resolve dynamic nodes by using browse paths.
    • Event filter. An optional configuration that selects and renames fields in the event notification. For more information, see Select and rename event fields.

    Screenshot that shows adding events in the operations experience.

  3. Select Manage default settings to configure default event settings for the asset. These settings apply to all the OPC UA events that belong to the asset. You can override these settings for each event that you add. Default event settings include:

    • Publishing interval (milliseconds): The rate at which OPC UA server should publish data.
    • Queue size: The depth of the queue to hold the sampling data before publishing it.

Review your changes

Review your asset and OPC UA data point and event details. Make any adjustments you need:

A screenshot that shows how to review your asset, data points, and events in the operations experience.

Add management groups and actions

A management group is a logical grouping of actions that you can invoke against an OPC UA asset, such as writing a value to a tag or calling a method. Actions must belong to a management group.

To create a management group and define actions for it, see Control OPC UA servers. That article explains the different types of actions (simple writes, complex writes, and method calls) and the MQTT topics you use to invoke them.

Update an asset

Find and select the asset you created previously. Use the Asset details, data points, and Events tabs to make any changes:

A screenshot that shows how to update an existing asset in the operations experience.

On the view data points tab for a dataset, you can add data points, update existing data points, or remove data points.

To update a data point, select an existing data point and update the data point information. Then select Update:

A screenshot that shows how to update an existing data point in the operations experience.

To remove data points, select one or more data points and then select Remove data points:

A screenshot that shows how to delete a data point in the operations experience.

You can also add, update, and delete events and properties in the same way.

When you're finished making changes, select Save to save your changes.

Delete an asset

To delete an asset, select the asset you want to delete. On the Asset details page, select Delete. Confirm your changes to delete the asset:

A screenshot that shows how to delete an asset from the operations experience.

Configure advanced endpoint behavior

By default, each asset opens a dedicated OPC UA session. You can configure assets to share an endpoint session and enable active and passive connector instances for high availability. To compare these modes and configure endpoint behavior, see Configure OPC UA sessions and high availability.