I wrote up a custom dotnet core template to create a starting point for Azure IoT Edge modules targeting OPC-UA communication as a client. There is a project for connecting to OPC-UA devices called OPC Publisher for Azure IoT Edge
This reference implementation demonstrates how Azure IoT Edge can be used to connect to existing OPC UA servers and publishes JSON encoded telemetry data from these servers in OPC UA “Pub/Sub” format (using a JSON payload) to Azure IoT Hub. All transport protocols supported by Azure IoT Edge can be used, i.e. HTTPS, AMQP and MQTT (the default).
which sounds promising but lacks some integration into the Azure IoT Edge message queuing system and module twin properties updates. Also I just wanted to have a simple client to call a device that’s it.
To install the .NET Core template for your command line you can simply
this will download and install the template for your command line interface. Check with executing
dotnet new if the template is successfully installed
To setup a new project simply run
MyOpcModule should be exchanged with the name you want to have for your module.
This project includes a variety of code assets. Based on the .NET Standard Library samples from the OPC Foundation I included all necessary code plumbing to make a fresh start easier.
This file implements the partial class
Module. It has all the necessary OPC-UA plumbing to connect to the device and provides session handling.
This is the other partial class implementation of
Module. This file is responsible for integrating into the queueing of Azure IoT Edge and also implements module twin update handling.
Here you define the configuration for your module which will be updated via module twin updates.
There are three different Dockerfiles provided. One for linux-x64, Windows nano-containers and Linux-ARM 32bit.
The template is also available in a public Github repo https://github.com/dariuszparys/edgev2-opc-client in case you prefer to modify it or just want to have a look without installing the template itself.
I also have another project on Github where you can see the OPC Foundation .NET Core sample client and server running in Azure IoT Edge with install scripts provided for easier testing.
OPC-UA communication is one of the standards Azure IoT Edge supports through various ways. This template should make a good starting point to get fast onboarded.