Azure/device-telemetry-dotnet

Name: device-telemetry-dotnet

Owner: Microsoft Azure

Description: Device telemetry implementation in .NET for PCS

Created: 2017-06-20 20:51:02.0

Updated: 2018-03-30 19:46:32.0

Pushed: 2018-03-30 23:17:56.0

Homepage: null

Size: 179

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Issues Gitter

Device Telemetry Overview

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

Why?

This microservice was built as part of the Azure IoT Remote Monitoring project to provide a generic implementation for an end-to-end IoT solution. More information here.

Features
Documentation

How to use

Running the service with Docker

You can run the microservice and its dependencies using Docker with the instructions here.

Running the service locally
Prerequisites
1. Deploy Azure Services

This service has a dependency on the following Azure resources. Follow the instructions for Deploy the Azure services.

2. Setup Dependencies

This service depends on the following repository.

  1. Storage Adapter Microservice
3. Environment variables required to run the service

In order to run the service, some environment variables need to be created at least once. See specific instructions for IDE or command line setup below for more information. More information on environment variables here.

Running the service with Visual Studio
  1. Make sure the Prerequisites are set up.
  2. 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).
  3. Open the solution in Visual Studio
  4. Edit the WebService project properties by right clicking on the Webservice project > Properties > Debug. Add following required environment variables to the Debug settings. In Windows you can also set these in your system.
  5. PCS_TELEMETRY_DOCUMENTDB_CONNSTRING = {your Azure Cosmos DB connection string}
  6. PCS_STORAGEADAPTER_WEBSERVICE_URL = http://localhost:9022/v1
  7. In Visual Studio, start the WebService project
  8. Using an HTTP client like Postman, use the RESTful API to test out the service.
Running the service from the command line
  1. Make sure the Prerequisites are set up.
  2. Set the following environment variables in your system. More information on environment variables here.
    1. PCS_TELEMETRY_DOCUMENTDB_CONNSTRING = {your Azure Cosmos DB connection string}
    2. PCS_STORAGEADAPTER_WEBSERVICE_URL = http://localhost:9022/v1
  3. Use the scripts in the scripts folder for many frequent tasks:
  4. build: compile all the projects and run the tests.
  5. compile: compile all the projects.
  6. run: compile the projects and run the service. This will prompt for elevated privileges in Windows to run the web service.
Project Structure

This microservice contains the following projects:

Updating the Docker image

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

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:

Contributing to the solution

Please follow our contribution guidelines. We love PRs too.

Feedback

Please enter issues, bugs, or suggestions as GitHub Issues.

License

Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.


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.