ms-iot/device-telemetry-dotnet

Name: device-telemetry-dotnet

Owner: ms-iot

Description: Device telemetry implementation in .NET for PCS

Forked from: Azure/device-telemetry-dotnet

Created: 2017-12-16 00:42:03.0

Updated: 2018-04-30 19:20:09.0

Pushed: 2017-12-16 00:45:40.0

Homepage: null

Size: 153

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Issues Gitter

Device Telemetry Overview

This service offers read access to device telemetry, full CRUD for rules, and read/write for alarms from storage for the client via a RESTful endpoint.

Features the microservice offers:
  1. Gets a list of telemetry messages for specific parameters
  2. Gets a list of alarms for specific parameters
  3. Gets a single alarm
  4. Modifies alarm status
  5. Create/Read/Update/Delete Rules
    1. Create Rules
    2. Gets a list of rules for specific parameters
    3. Gets a single rule
    4. Modify existing rule
    5. Delete existing rule

Dependencies

  1. DocumentDB Storage
  2. Storage Adapter Webservice

How to use the microservice

Quickstart - Running the service with Docker
  1. Create an instance of Azure Document Db
  2. Follow the Storage quickstart instructions for setting up the Storage Adapter microservice storage.
  3. Find your DocumentDb connection string. See See the tip here if you need help finding it.
  4. Store the “Document Db Connection string” in the env-vars-setup script, then run the script. In MacOS/Linux the environment variables need to be set in the same session where you run Docker Compose, every time a new session is created.
  5. Install Docker Compose
  6. Start the Telemetry service using docker compose:
    cripts
    ocker
    er-compose up
    
  7. Use an HTTP client such as Postman, to exercise the RESTful API
Local Setup
1. Environment Variables

Run scripts\env-vars-setup.cmd on Windows or source scripts\env-vars-setup on Mac/Linux to set up the environment variables needed to run the service locally. In Windows you can also set these in your system.

If using envornemnt variables, this service requires the following environment variables to be set:

  1. PCS_TELEMETRY_DOCUMENTDB_CONNSTRING = {your Azure Document Db connection string}
  2. PCS_STORAGEADAPTER_WEBSERVICE_URL = http://localhost:9022/v1
Running the service with Visual Studio
  1. Install any edition of Visual Studio 2017 or Visual Studio for Mac. When installing check “.NET Core” workload. If you already have Visual Studio installed, then ensure you have .NET Core Tools for Visual Studio 2017 installed (Windows only).
  2. Create an instance of Azure Document Db
  3. Follow the Storage quickstart instructions for setting up and running the Storage Adapter microservice.
  4. Open the solution in Visual Studio
  5. Edit the WebService project properties, and define the following required environment variables. In Windows you can also set these in your system.
  6. PCS_TELEMETRY_DOCUMENTDB_CONNSTRING = {your Azure Document Db connection string}
  7. PCS_STORAGEADAPTER_WEBSERVICE_URL = http://localhost:9022/v1
  8. In Visual Studio, start the WebService project
  9. Using an HTTP client like Postman, use the RESTful API
Project Structure

The solution contains the following projects and folders:

Build and Run from the command line

The scripts folder contains scripts for many frequent tasks:

Building a customized Docker image

The scripts folder includes a docker subfolder with the scripts required to package the service into a Docker image:

You can also start Device Telemetry and its dependencies in one simple step, using Docker Compose with the docker-compose.yml file in the project:

cripts
ocker
er-compose up

The Docker compose configuration requires the Storage and StorageAdapter web service URL environment variables, described previously.

Configuration and Environment variables

The service configuration is stored using ASP.NET Core configuration adapters, in appsettings.ini. The INI format allows to store values in a readable format, with comments. The application also supports references to environment variables, which is used to import credentials and networking details.

The configuration files in the repository reference some environment variables that need to be created at least once. Depending on your OS and the IDE, there are several ways to manage environment variables:

Other resources

Contributing to the solution

Please follow our contribution guidelines. We love PRs too.

Troubleshooting

{TODO}

Feedback

Please enter issues, bugs, or suggestions as GitHub Issues here: https://github.com/Azure/device-telemetry-dotnet/issues.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.