This is an Azure IoT Edge sample showing how to store machine data from OPC-UA servers locally in a single node CrateDB database. All necessary components will be deployed by Azure IoT Edge.
To be able to run this sample on your edge device, you'll have Azure IoT Edge installed on the device, including a container runtime like Docker. The sample was developed on a Windows 10 IoT machine with Docker Desktop and Linux container.
Since this sample was developed with Visual Studio Code, the easiest way to run the sample is by using Visual Studio Code with the according Azure IoT Edge Plugin, as used for custom module development of Azure IoT Edge.
Before starting to deploy the sample to the edge device, the local CrateDB used in the sample has to be created first. An existing CrateDB in the local network could be used, too, but this sample uses CrateDB running in a container on the same device as the Azure IoT Edge runtime.
- Create a folder on the disk for the CrateDB database files, e.g.
C:\Dev\docker\mounts\crate\data - Run CrateDB locally from the command line by using
docker run -p "4200:4200" -d --rm --name cratedb -v C:\Dev\docker\mounts\crate\data:/data crateand replace it with the folder you have created before in step 1 - Open a web browser with
http://localhost:4200and go to the CrateDB console - Create the tables and the user by executing all SQL Statements in the file
./scripts/createTable.sql - Stop the container with
docker container stop cratedb - Edit the files
deployment.template.jsonanddeployment.debug.template.jsonby changing the database folder location fromC:/Dev/docker/mounts/crate/datato your database files location (as done in step 1)
- Per default this sample uses all nodes from the OPC-UA Server simulation. If you want to change the setup, just edit the
publishednodes.jsonfile in the folderappdata - Edit the files
deployment.template.jsonanddeployment.debug.template.jsonby changing the publisher's data folder fromC:/Dev/iotedge/crate/localstorageCrateDBEdgeSolutionto the directory you've downloaded the source repository on your local disk.
Easiest way to run the sample is by using Visual Studio Code.
