Last active
February 19, 2017 13:33
-
-
Save snobu/c05da15bf040afb22736f3602cb503cf to your computer and use it in GitHub Desktop.
FuncApp-DocDB-Binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "bindings": [ | |
| { | |
| "type": "eventHubTrigger", | |
| "name": "myEventHubMessage", | |
| "direction": "in", | |
| "path": "marioevents", | |
| "connection": "breakingnews" | |
| }, | |
| { | |
| "type": "documentDB", | |
| "name": "outputDocument", | |
| "databaseName": "marioeventsdb", | |
| "collectionName": "MarioCollection", | |
| "createIfNotExists": true, | |
| "connection": "seriously_DOCUMENTDB", | |
| "direction": "out" | |
| } | |
| ], | |
| "disabled": false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #r "Newtonsoft.Json" | |
| using System; | |
| using Newtonsoft.Json; | |
| public static void Run(string myEventHubMessage, ICollector<object> outputDocument, TraceWriter log) | |
| { | |
| log.Info($"Event: {myEventHubMessage}"); | |
| var msg = JsonConvert.DeserializeObject<MarioEvent>(myEventHubMessage as string); | |
| // Write to DocumentDB | |
| outputDocument.Add( | |
| new MarioEvent() { | |
| DeviceId = msg.DeviceId, | |
| Application = msg.Application, | |
| Event = msg.Event | |
| }); | |
| } | |
| public class MarioEvent | |
| { | |
| public string DeviceId { get; set; } | |
| public string Application { get; set; } | |
| public string Event { get; set; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment