Azure Industrial IoT OPC UA Device Twin Edge Module
Clone or download
marcschier 1.0.1 rc3
* Split protocol code into standalone assembly
* Create injectable services as adapters of rest api.
* Add historic access to twin api
* Several fixes and addition of publisher api updates
Latest commit 1a73588 Nov 21, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
docker 1.0.0-preview009 release Sep 20, 2018
version.props Start 1.0.1 Nov 19, 2018

Azure Industrial IoT OPC Device Twin Module

The OPC Device Twin module runs on the edge and provides serveral edge services to the OPC Device Twin and Registry Services.

Core of the module is the Supervisor identity. The supervisor manages endpoint "twins", which correspond to OPC UA server endpoints that are activated using the corresponding OPC UA registry API. These endpoint twins translate OPC UA JSON received from the Twin micro service running in the cloud into OPC UA binary messages which are sent over a stateful secure channel to the managed endpoint.

The supervisor also provides discovery services which send device discovery events to the OPC UA Device Onboarding service for processing, where these events result in updates to the OPC UA registry.

The OPC Device Twin module can be deployed in an IoT Edge gateway. For development and testing purposes it can also be run standalone following the instructions below. This module is part of our Azure Industrial IoT (IIoT) components suite.

Getting started

Install any tools and depdendencies

Deploy Azure Services

Follow the instructions here to deploy all required services and retrieve the module configuration information, in particular the value for the PCS_IOTHUB_CONNSTRING environment variable, which will be needed later on.

Build and Run

Building and running locally using Docker (Quick start mode)

  1. Make sure the Prerequisites are set up.
  2. Change into the repo root and ensure the .env file containing an entry for PCS_IOTHUB_CONNSTRING exists.
  3. Start the module by running docker-compose up.

Also, make sure you run one or more OPC UA servers in a network reachable from your development machine to utilize the OPC UA Twin capabilities.

Build, run and deploy the module to IoT Edge (Production)

  1. Make sure the Prerequisites are set up.
  2. Change into the repo root and build the quick start docker image using docker build -f docker/linux/amd64/Dockerfile -t azure-iiot-opc-twin-module .
  3. Push the module to an accessible registry, e.g. Azure Container Registry, or dockerhub.
  4. Follow the instructions on how to deploy the module to IoT Edge:
  • Instructions on how to deploy a module to one or a set of IoT Edge targets.
  • Instructions on how to install IoT Edge on Linux and on Windows.

Install one IoT Edge target per your factory network. Make sure you run one or more OPC UA servers in the same network to utilize the OPC Twin capabilities.

Building and running the module with Visual Studio or VS Code

  1. Make sure the Prerequisites are set up.
  2. Set the PCS_IOTHUB_CONNSTRING environment variable in your system.
  • This page describes how to setup env vars in Windows.
  • For Linux and MacOS, we suggest to create a shell script to set up the environment variables each time before starting the service host (e.g. VS Code or docker). Depending on OS and terminal, there are ways to persist values globally, for more information this, this, or this page should help.
  1. Open the solution in Visual Studio or VS Code
  2. Configure the Microsoft.Azure.IIoT.OpcUa.Modules.Twin.Cli project properties to pass --host as command line argument when starting.
  3. Start the Microsoft.Azure.IIoT.OpcUa.Modules.Twin.Cli project (e.g. press F5).

Other Azure Industrial IoT components


Refer to our contribution guidelines.


Please enter issues, bugs, or suggestions as GitHub Issues here.


Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.