Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 2.27 KB

File metadata and controls

48 lines (32 loc) · 2.27 KB

Azure IoT Device Simulator (.NET 5, C#) - DPS version - How To

How to use the Azure IoT Device Simulator?

You can use the source code to compile the application and use it as a regular C# .NET 5 Console application. This may be enough if you need the simulator as a development tool.

If you need instead a reusable simulator and create more than one instance of the simulator, you will probably prefer to containerize it. This may be particularly interesting if you want to create a set of simulated devices. This folder contains same examples about how to do that.

Docker prerequisites

In order to use a Docker container, you need to check Docker prerequisites.

Do not forget you will need an internet connection with specific open ports:

  • 8883
  • 5671
  • 443

Ports required to communicate with Microsoft Azure IoT Hub.

Steps to run the simulator

The Azure IoT Device Simulator needs three basic things before starting:

  • Required: settings (need to be updated with proper values)
  • Required: message templates (included by default)
  • Optional (needed for module identities): deploy the REST API exposing the Azure IoT Hub Service SDK (this is required because module identities cannot be created from the Azure IoT Hub Device SDK). The code is provided. It can also be containerized.

Settings

All the settings except those related to DPS rely on JSON files. DPS settings can be provided through 3 different ways (details).

JSON files

  • appsettings.json
  • devicesettings.json
  • modulessettings.json
  • dpssettings.json

This section explains in details all these files.

Tip

The solution takes into account settings depending on the environment. The environment can be set trough the environment variable ENVIRONMENT. The solution looks for settings files following the pattern file.ENVIRONMENT.json (similar to former transformation files). Default setting files will be loaded first in case no environment file is found.