Edge proxy is an IoT Edge module that enables end-to-end connectivity to your Edge device using device streams. Ensure your IoT Hub/edge is provisioned in one of the supported regions.
To set up edge proxy for trial purposes, you need to:
device_connection_string
in edge-config.yaml
with its connection stringVagrantfile
in this repo to provision the VM by running:
# Provision and bring up your vagrant VM
vagrant up
Once done, check that IoT Edge runtime is active and edgeAgent is running:
# SSH to your vagrant VM
vagrant ssh
# Output of command below should show the daemon is in 'active (running)' state
sudo systemctl status iotedge
# Output of command below should show 'edgeAgent' module in 'running' state
# Note that it may take a few minutes for the module to be downloaded
sudo iotedge list
In your cloned repository folder, run:
docker build -t <image_name> .
docker push <image_name>
You can skip this step and use pre-built image rezas/edgeproxy:0.40_mqtt
that is published here.
Register a regular IoT device and remember the device name and the connection string
Register and create IoT Edge device, make sure it's running ok
Add a deployment module using Set modules
In Image URI, fill in rezas/edgeproxy:0.40_mqtt
to use the pre-published image or use the image_name
you porvided here
In Environment Variables, add these three fields
Name | Value | Comment |
---|---|---|
TARGET_IP | 172.17.0.1 | This is the local IP address of the host as seen by an IoT Edge module/container |
TARGET_PORT | 22 | Port for SSH |
CONNECTIONSTRING | <Connection string of the regular device your created in step 1> | This module has its own connection to IoT Hub for the Hackathon |
Click next, next, next, then Submit
It'll take a while to pull the image, so wait a while till you see the module is running
Follow instructions to sideload the extension and login
Proxy the stream:
az iot hub proxy -n [hub] -d [device created earlier] --port [port]
Open another terminal window
Use a valid username and credentials to SSH to your IoT edge device.
ssh -p [port] username@localhost
For the case of vagrant, use ssh -i .vagrant/machines/default/virtualbox/private_key -p 2222 vagrant@localhost
. Note you need to use the private key of your Vagrant VM (this is usually stored in your provisioned VM folder under .vagrant/machines/default/virtualbox/private_key
.
# Use a valid device connection string
CONNECTIONSTRING=""
# Default value is localhost (container itself)
export TARGET_IP=$HOSTNAME
# Default value is 22
export TARGET_PORT=22
docker run \
--env CONNECTIONSTRING="$CONNECTIONSTRING" \
--env TARGET_IP="$TARGET_IP" \
--env TARGET_PORT="$TARGET_IP" \
-it \
<image_name>