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 "Microsoft.Azure.Documents.Client" | |
using Microsoft.Azure.Documents; | |
using Microsoft.Azure.Documents.Client; | |
using System.Net; | |
using System.Configuration; | |
private static string endpointUrl = ConfigurationManager.AppSettings["cosmosDBAccountEndpoint"]; | |
private static string authorizationKey = ConfigurationManager.AppSettings["cosmosDBAccountKey"]; | |
private static DocumentClient client = new DocumentClient(new Uri(endpointUrl), authorizationKey); |
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 "Microsoft.Azure.Documents.Client" | |
using Microsoft.Azure.Documents; | |
using Microsoft.Azure.Documents.Client; | |
using System.Net; | |
private static string endpointUrl = ConfigurationManager.AppSettings["cosmosDBAccountEndpoint"]; | |
private static string authorizationKey = ConfigurationManager.AppSettings["cosmosDBAccountKey"]; | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
{ |
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 "System.Runtime.Serialization" | |
using System.Net; | |
using System.Runtime.Serialization; | |
// Define the class that will get sent on the HTTP body | |
// DataContract is used to support XML | |
[DataContract(Name = "Query", Namespace = "http://functions")] | |
public class Query { |
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": [ | |
{ | |
"name": "query", | |
"type": "httpTrigger", | |
"direction": "in" | |
}, | |
{ | |
"name": "$return", | |
"type": "http", |
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
module.exports = function (context, req) { | |
var documents = context.bindings.documents; | |
var totalDocuments = documents.length; | |
context.log('Found '+ totalDocuments +' documents'); | |
if(totalDocuments === 0){ | |
context.res = { | |
status: 404, | |
body : "No documents found" | |
}; |
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": [ | |
{ | |
"name": "classes", | |
"type": "httpTrigger", | |
"direction": "in" | |
}, | |
{ | |
"name": "$return", | |
"type": "http", |
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
using System.Net; | |
public class MyClass { | |
public string id {get;set;} | |
public string name {get;set;} | |
} | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, MyClass[] classes, TraceWriter log, IAsyncCollector<MyClass> documentsToStore) | |
{ | |
log.Info($"Detected {classes.Length} incoming documents"); |
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
module.exports = function (context, req) { | |
context.log('Detected ' + req.body.length + ' incoming documents'); | |
context.bindings.documentsToStore = []; | |
for(let i = 0, len=req.body.length; i<len;i++){ | |
const doc = req.body[i]; | |
context.bindings.documentsToStore.push(doc); | |
} | |
context.done(null, { |
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
[ | |
{ | |
"id":"1", | |
"name": "John", | |
"surname": "McClane" | |
}, | |
{ | |
"id":"2", | |
"name": "John", | |
"surname": "Rambo" |
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
module.exports = function(context, input) { | |
if(!!input && input.length > 0){ | |
context.bindings.docsToSave = []; | |
for(let i = 0, len=input.length; i<len;i++){ | |
const doc = input[i]; | |
// Do something here with the doc or create a new one | |
context.bindings.docsToSave.push(doc); | |
} | |
} |
OlderNewer