Code Monkey home page Code Monkey logo

azure-iot-edge-device-container's Introduction

azure-iot-edge-device-container

An Azure IoT Edge Device in a Docker container with x64 / arm32 support

Docker Build Status Docker Pulls

Create a self-provisioning Edge Device Container Instance

Create an Azure IoT Hub

Install the Azure-Cli

Run az login to sign in with the azure cli and set the appropriate subscription with:

az account set --subscription

Create a Service Principal for your subscription with the azure cli:

az ad sp create-for-rbac --name <name> --password <password>

You should see output similar to:

{
"appId": "12345678-1234-1234-1234-1234567890ab",
"displayName": "azure-iot-edge-device-container-sp",
"name": "http://azure-iot-edge-device-container-sp",
"password": "MyPassword",
"tenant": "abcdefgh-abcd-abcd-abcd-abcdefghijkl"
}

Take note of the name, password, and tenant as these values will be used later for <spAppURl>, <spPassword>, and <tenant> respectively.

Obtain the following Parameters:

Parameter Description
spAppUrl The Service Principal app URL Required
spPassword The Password for the Service Principal Required
tenantId The tenant id for the Service Principal Required
subscriptionId The azure subscription id where the IoT Hub is deployed Required
iothub_name The name of the Azure IoT Hub Required
environment A value to use for the envrionment tag in the created device's devicetwin Optional

Start a container instance with:

docker run -it -d --privileged -e spAppUrl='<spAppUrl>' -e spPassword='<spPassword>' -e tenantId='<tenantId>' -e subscriptionId='<subscriptionId>' -e iothub_name='<iothub_name>' -e environment='<environment>' toolboc/azure-iot-edge-device-container

The device will automatically register itself as an Edge device within the specified IoT Hub using the hostname of the container instance.

You can use the environment tag to specify a Target Condition to apply apply an IoT Deployment definition.

Edge Deployment Configuration

Create an Edge Device Container Instance using an existing device connection string

Obtain the device connection string: Edge Device Connection String

Start a container instance with:

docker run -it -d --privileged -e connectionString='<IoTHubDeviceConnectionString>' toolboc/azure-iot-edge-device-container

Deploy multiple Edge Device Container Instances to K8s using Helm:

Create an Azure Kubernetes Service Install helm and install tiller in your cluster

Navigate to the helm directory in this repo and execute the following:

helm install --name azure-iot-edge-device-container azure-iot-edge-device-container --set spAppUrl=<spAppUrl> --set spPassword=<spPassword> --set tenantId=<tenantId> --set subscriptionId=<subscriptionId> --set iothub_name=<iothub_name> --set environment=<environment> --set replicaCount=1

Use iotedge cli within the Edge Device Container Instance

You can use the iotedge cli within the docker container.

For example, when running a single instance in docker, you can open an interactive shell by running:

docker exec -it <containerid> bash

Then, within that interactive shell, run the following command to list the modules on your edge device, or any other iotedge command you wish:

iotedge list

To exit the interactive shell, simply run the following within the interactive shell:

exit

Use iotedge cli from the Host

First you need to have the Azure IoT Edge Runtime Installed on your host machine.
Find the container id for the Edge Device Container Instance by running the following command to obtain the CONTAINER ID value for the azure-iot-edge-device-container.

docker container list

Next, you need to inspect the Edge Device Container Instance using the following command on the host machine:

docker inspect <containerid>

In the output look for the IPAddress value:

IPAddress

Then, using that IP address you can run the following from the host machine:

docker exec <containerid> iotedge -H http://<IPAddress>:15580 list

For example, if the container id for your Edge Device Container Instance started with 0a and the IPAddress value for your container was 172.17.0.2 you could run:

docker exec 0a iotedge -H http://172.17.0.2:15580 list

iotedge list

azure-iot-edge-device-container's People

Contributors

bretstateham avatar toolboc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.