Skip to content

Instantly share code, notes, and snippets.

View jplane's full-sized avatar

Josh Lane jplane

  • Microsoft
  • Atlanta GA, USA
  • X @jplane
View GitHub Profile
@jplane
jplane / mapcontroller.cs
Created September 29, 2016 22:23
Web API controller to query IoT device metadata
public class MapController : ApiController
{
[Route("api/map/{id}")]
public object Get(int id)
{
var uri = new Uri(ConfigurationManager.AppSettings["docdbUri"]);
var key = ConfigurationManager.AppSettings["docdbKey"];
var dbName = ConfigurationManager.AppSettings["docdbDatabaseName"];
var collName = ConfigurationManager.AppSettings["docdbCollName"];
@jplane
jplane / iot-eventconsumer.cs
Created September 29, 2016 22:14
Processing messages from an IoT Hub using EventProcessorHost and friends...
public async Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
{
// configure REST client
var client = new HttpClient();
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["webUrl"]);
var save = false;
// process incoming messages
foreach (var msg in messages)