Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
log.LogInformation("DPS processed a request. ");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
log.LogInformation("Linked Hub:");
foreach(var item in data.linkedHubs)
log.LogInformation((string) item);
var response = new Response("");
response.initialTwin.tags = new JObject();
response.initialTwin.tags.tagOne = "one"; = new JObject(); = "ONE"; = new JObject(); = "attrib one";
return (ActionResult) new OkObjectResult(response);
public class Response
public Response(string hostName)
iotHubHostName = hostName;
initialTwin = new ResponseTwin();
public string iotHubHostName {get; set;}
public ResponseTwin initialTwin {get; set;}
public class ResponseTwin
public ResponseTwin()
properties = new ResponseProperties();
public dynamic tags {get; set;}
public ResponseProperties properties {get; set;} // contains desired properties
public class ResponseProperties
public dynamic desired {get; set;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.