GithubHelp home page GithubHelp logo

azureiotclient's Introduction

Docker and Azure IoT device client

This repository is an example of how to build and run a Docker image that contains a Java based Azure IoT device client.

Table of Contents

Features

You can execute the Java based IoT device client using a Docker image or in standalone Java application mode.

The IoT device client sample in this repository is based on the Azure IoT SDK and sample apps . Please visit the link above to become familiar with the capabilities of the Azure IoT device Java SDK.

This implementation extends the Azure samples with the following features: * Send messages using a configurable interval. * Simulate multiple devices each of which can send messages at configured inteval. * Multi-device simulation for AMQPS is currently not supported. * Sends an eventcontaining temperature, humidity and device timestamp in JSON format. * Self-registration of IoT Devices using the RegistryManager API, no pre-registration required. * Clean-up and delete auto-registered IoT devices after each run using

The event is sent using the following JSON format:

       {"deviceId":"io.github.stansa.azureiotsample:f6b51682-5c54-4186-af47-b43277c81b74","timestamp":"2016-02-29T19:57:11.780Z","temperature":7.0,"humidity":55.0}

Run using Docker

Minimal Docker image to run Java applications. This is based on Alpine Linux to keep the size minimal (about 25% of an ubuntu-based image).

Images on Docker Hub:

https://hub.docker.com/r/stans/azureiotclient/

Tags

  • latest : Run a device simulation
  • cleanup: Cleanup devices from Registry

Usage

Example of running a simulation for a single IoT device client:

    docker run -e "PROTOCOL=amqps" -e "HUB_CONN_STRING=HostName=company1.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=Abcdefghijklmnopqrstuvwxyz=” stans/azureiotclient

Example of cleanup and deletion of IoT device client created during the simulation:

    docker run -e "HUB_CONN_STRING=HostName=company1.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=Abcdefghijklmnopqrstuvwxyz=” stans/azureiotclient:cleanup

Scaling IoT device clients

  1. Run using Azure Container Service https://azure.microsoft.com/en-us/documentation/articles/container-service-intro/

  2. Run using Docker Cloud and Microsoft Azure integration https://docs.docker.com/docker-cloud/getting-started/link-azure/

  3. Roll your own orchestration using Azure VMs and/or Docker Swarm: https://docs.docker.com/swarm/overview/

  4. Run on any other Docker compliant container service such as AWS Container Service

Run as standalone Java application:

  • create a jar - ./mvn clean package

  • go to target/ to find the azureiot-1.0-SNAPSHOT-with-deps.jar

  • execute java -jar

    java -jar -Dazureiot_num_devices= -Dazureiot_device_data_interval= -Dazureiot_conn_string= -Dazureiot_protocol="https|mqtt_amqps" azureiot-1.0-SNAPSHOT-with-deps.jar

    java -jar -Dazureiot_num_devices=3 -Dazureiot_device_data_interval=15  -Dazureiot_conn_string=HostName=company1.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=Abcdefghijklmnopqrstuvwxyz=" -Dazureiot_protocol="mqtt"  azureiot-1.0-SNAPSHOT-with-deps.jar 
    

To delete self-registered devices, execute the jar with the CleanupRegistry main class:

  java -jar -Dazureiot_conn_string=HostName=company1.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=Abcdefghijklmnopqrstuvwxyz=" azureiot-1.0-SNAPSHOT-with-deps.jar io.github.stansa.azureiotsample.CleanUpRegistry

azureiotclient's People

Contributors

stansa 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.