Skip to content

Latest commit

 

History

History
141 lines (92 loc) · 5.86 KB

iot-accelerators-device-simulation-deploy-image.md

File metadata and controls

141 lines (92 loc) · 5.86 KB
title description author manager ms.service services ms.topic ms.custom ms.date ms.author
Deploy a custom Device Simulation image - Azure| Microsoft Docs
In this how-to guide, you learn how to deploy a custom Docker image of the Device Simulation solution to Azure.
dominicbetts
timlt
iot-accelerators
iot-accelerators
conceptual
mvc
11/06/2018
dobett

Deploy a custom Device Simulation docker image

You can modify the Device Simulation solution to add custom features. For example, the Serialize telemetry using Protocol Buffers article shows you how to add a custom device to the solution that uses Protocol Buffers (Protobuf) to send telemetry. After you've tested your changes locally, the next step is to deploy your changes to your Device Simulation instance in Azure. To complete this task, you need to create and deploy a Docker image that contains your modified service.

The steps in this how-to-guide show you how to:

  1. Prepare a development environment
  2. Generate a new Docker image
  3. Configure Device Simulation to use your new Docker image
  4. Run a simulation using the new image

Prerequisites

To complete the steps in this how-to guide, you need:

The instructions in this article assume you're using Windows. If you're using another operating system, you may need to adjust some of the file paths and commands to suit your environment.

Create a new Docker image

To deploy your own changes to the Device Simulation service, you need to edit the build and deployment scripts in scripts\docker folder to upload the containers to your docker-hub account

Modify the docker scripts

Modify the Docker build.cmd, publish.cmd, and run.cmd scripts in the scripts\docker folder with your Docker Hub repository information. These steps assume you created a public repository called device-simulation:

DOCKER_IMAGE={your-docker-hub-username}/device-simulation

Update the docker-compose.yml file as follows:

image: {your-docker-hub-username}/device-simulation

Configure the solution to include any new files

If you added any new device model files, you need to explicitly include them in the solution. Add an entry to the services/services.csproj for each additional file to include. For example, if you completed the Serialize telemetry using Protocol Buffers how-to, add the following entries:

<None Update="data\devicemodels\assettracker-01.json">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="data\devicemodels\scripts\assettracker-01-state.js">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

Generate new Docker images and push to Docker Hub

Publish the new Docker image to Docker Hub using your docker-hub account:

  1. Open a command prompt and navigate to your local copy of the device simulation repository.

  2. Navigate to the docker folder:

    cd scripts\docker
  3. Run the following command to build the Docker image:

    build.cmd
  4. Run the following command to publish the Docker image to your Docker Hub repository. Sign in to Docker with your Docker Hub credentials:

    docker login
    publish.cmd

[!INCLUDE iot-solution-accelerators-access-vm]

Update the service

To update the Device Simulation container to use your custom image, complete the following steps:

  • Use SSH to connect to the virtual machine hosting your Device Simulation instance. Use the IP address and password you made a note of in the previous section:

    ssh azureuser@{your vm ip address}
  • Navigate to the /app directory:

    cd /app
  • Edit the docker-compose.yml file:

    sudo nano docker-compose.yml

    Modify the image to point the custom device-simulation image you uploaded to your Docker Hub repository:

    image: {your-docker-hub-username}/device-simulation

    Save your changes.

  • Run the following command to restart the microservices:

    sudo start.sh

Run your Simulation

You can now run a simulation using your customized Device Simulation solution:

  1. Launch your Device Simulation web UI from Microsoft Azure IoT Solution Accelerators.

  2. Use the web UI to configure and run a simulation. If you previously completed Serialize telemetry using Protocol Buffers, you can use your custom device model.

Next steps

Now you've learned how to deploy a custom Device Simulation image, you may want to learn how to Use an existing IoT hub with the Device Simulation solution accelerator.