When you follow the docs of Azure IoT Edge to setup it on an Linux machine there is the point when installing the Azure IoT Edge control scripts require sudo permissions. I’ll show you a way without that

Setting up VirtualEnv for Python

First of all the iotedgectl script is Python based and I’ll leverage virtualenv to keep the scripts in one virtual environment I will work with.

I assume that you have already the latest version of pip installed, if not just follow these instructions.

Let’s install the virtual python environment tooling.

1
2
sudo pip install virtualenv
sudo pip install virtualenvwrapper

To use the commands mkvirtualenv and rmvirtualenv add the following to your bash initialization script.

1
2
3
export WORKON_HOME=~/.envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh

Source or restart the bash and start using the virtual environment. As the Azure IoT Edge CLI will be used on different projects there is no need to associate the virtual environment with a specific directory. To create the virtual environment type

1
mkvirtualenv azure-iot-edge

This will install a new python executable and the basic tools for distribution. Also the environment is now active. You can simple type in deactivate to leave the virtual environment and to use it again just activate it via workon azure-iot-edge.

Installing iotedgectl

To install now the Azure IoT Edge CLI simply install it using pip while working in the azure-iot-edge environment

1
(azure-iot-edge) -> ~ pip install azure-iot-edge-runtime-ctl

You can verify that the script is installed correctly in your virtual environment with the which command.

1
2
which iotedgectl
/home/dariusz/.envs/azure-iot-edge-bin/iotedgectl

Setting up the Edge Device

To setup the edge device you still need two additional parameters in order to be able to run it without sudo permissions. The edge configuration and home directory has to be a path where your user account has permission to. In my case I just remapped it to $HOME/.iotedgectl for the configuration and $HOME/.iotedgehome for the home directory.

The setup command would look like this

1
iotedgectl setup --connection-string "here goes your device connection string" --auto-cert-gen-force-no-passwords --edge-config-dir $HOME/.iotedgectl --edge-home-dir $HOME/.iotedgehome

Ready

Now your device is setup without the need of admin permissions. Everytime you want to activate the enviroment again all you have to do is to execute workon azure-iot-edge