# Under Construction
- An IoT Hub has been setup and configured in an Azure subscription that you have access to. If you need to understand how to configure an IoT Hub see this article.
- An Azure IoT Edge device has been configured on a device that is running Linux.
- If you need to understand how to install IoT Edge on x64 see this article.
- If you need help on how to install IoT Edge on Linux ARM32 see this article.
Once the Edge is running on a device (or VM) we need to ensure that it is healthy. To do this run the following command
sudo systemctl status iotedge
You should see an output like you see below:
The part to pay attention to is the bit in green "active (running)" This tells us that IoT Edge is installed and connected to an IoT Hub in Azure.
Next we need to create a file for the OPC Publisher configuration.
From the shell prompt in the terminal session type the following:
sudo mkdir /shared
Now we need to create our file in this directory. To do this we will type:
sudo nano /shared/pn.json
If nano is not your favorite editor...feel free to use what you like.
paste the following in the file.
[
{
"EndpointUrl": "opc.tcp://1xx.1xx.1xx.1xx:Port",
"UseSecurity": false,
"OpcNodes": [
{
"Id": "ns=2;s=Channel1.Device1.Tag1",
"OpcSamplingInterval": 2000,
"OpcPublishingInterval": 5000
}
]
}
]
Enter your OPC-UA Server's IP address and port number for the "EndpointURL".
Save this file.
EndpointUrl entry must contain the opc.tcp:// followed by the server's OPC server's IP address : and the OPC server's Port number.
UseSecurity
OpcNodes This is where you enter your Name Space and tags that you are wanting to sample and publish
-
ID This is where we will insert the OPC namespace and tags. The easiest way to find the tag and name space is to use a tool like UA Expert. For our discussions we will be using this tool. Once the tool is installed, open the tool. Once the tool starts up you will be asked to create a certificate. Enter the required data. Once UA Expert gets to the application view perform the following steps:
-
Now you should see your OPC Server listed under the "Servers" folder:
-
Right click on the OPC Server and select connect:
-
Now UA Expert should connect to your OPC Server. Once it does you can see the following "tree view" at the bottom pane:
-
Use the tree view to navigate to the tags that you are looking for and then drag them to the center pane.
-
In the following picture shows the "ID" section information. The NS shows the name space number "NS=2". The "String" is the "s" after the ";". and then everything in the third box makes up the rest of the string.
The next step is to install the module for OPC-UA Publisher. To do this you will need to log into the Azure Portal. Once you are on the Azure portal navigate to the resource group that holds your IoT Hub and select the IoT Hub.
On the IoT Hub blade select the IoT Edge on the left hand side.
On the IoT Edge blade find the IoT Edge device that we will be adding the OPC-UA Publisher to.
Select "Set Modules" at the top
Click on the Add as seen below:
Click on "Edge Module".
This will open a new fly out as scene below.
Here we will be filling in the following:
- Name
- iot-edge-opc-publisher
- Image URI
- microsoft/iot-edge-opc-publisher:latest
- Container Create Options
- Enter the following replacing the port binding port to the one that you are using in your OPC server deployment. Replace the with the OPC Server name and IP address as such: “KeithOPCserver1.useast.cloudapp.azure.com:10x.2xx.6x.1”
{
"Hostname": "publisher",
"Cmd": [
"publisher",
"--pf",
"/cfg/pn.json",
"--aa"
],
"HostConfig": {
"PortBindings": {
"62222/tcp": [
{
"HostPort": "62222"
}
]
},
"Binds": [
"test_cfx509certstores:/root/.dotnet/corefx/cryptography/x509stores",
"/shared:/cfg"
],
"ExtraHosts": [
"<OPC Server Host Name and IP>"
]
}
}
At the bottom of the blade you will see the , click next.
In the next section you will need to modify the route. Enter the following:
{
"routes": {
"upstream": "FROM /* INTO $upstream"
}
}
Check to see if the data is flowing in to the IoT hub. To do this we will type the following command at the shell prompt on the
Finally, for more information you can view this article, and this article