Skip to content

Instantly share code, notes, and snippets.

View christopheranderson's full-sized avatar
🪐
Making the Cosmos (DB) better

Christopher Anderson christopheranderson

🪐
Making the Cosmos (DB) better
View GitHub Profile
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
@christopheranderson
christopheranderson / project.json
Created April 4, 2016 17:58
Example Project.json for Azure Functions
{
"frameworks": {
"net46":{
"dependencies": {
"ChatWork.Api": "0.4.0"
}
}
}
}
@christopheranderson
christopheranderson / index.js
Created April 19, 2016 22:37
Simple verb routing for Azure Functions HTTP Trigger
module.exports = function(context, req) {
var method = req.method.toLowerCase();
context.log(JSON.stringify(req, null, " "));
if(methods[method]){
methods[method](context, req);
} else {
context.res = {
status: 404,
body: "No route found for VERB: " + req.method
}
@christopheranderson
christopheranderson / readme.md
Last active January 13, 2017 20:34
How to debug Node Azure Functions locally

How to debug Node Azure Functions locally

This is a guide on how to set up the Azure Functions CLI to debug functions locally.

🚧 WARNING - This is very experimental and not yet very easy. I'm writing up this guide for the brave few. WARNING 🚧

🐲 Beyond here be dragons. 🐲

Requirements

<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2017-01-25 22:48:35" build="161206">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Shells::PowerShell}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<value name="StartFarEditors" type="hex" data="00"/>
@christopheranderson
christopheranderson / query.sql
Created April 6, 2017 16:15
Analytics Query - Duration percentiles
requests
| where timestamp > ago(30m)
| summarize percentiles(duration, 50, 95, 99) by bin(timestamp, 1m)
| render timechart
{
"properties": {
"issue_description": {
"type": "number"
},
"issue_title": {
"type": "string"
}
},
"type": "object"
@christopheranderson
christopheranderson / host.json
Created May 10, 2017 00:58
Example config for App Insights pipeline
{
"logger": {
"categoryFilter": {
"defaultLevel": "Information",
"categoryLevels": {
"Host.Results": "Error",
"Function": "Error",
"Host.Aggregator": "Information"
}
},
@christopheranderson
christopheranderson / run.csx
Created September 8, 2017 20:31
Factory/Singleton pattern in Azure Functions
public class StartUpWork {
private static StartUpWork _singleton;
private string initializeOnce;
public StartUpWork() {
// Do long startup tasks/create database connection pools/whatever you want to happen once
this.initializeOnce = "Woooooo!";
}
public static StartUpWork ensureStartUp() {
@christopheranderson
christopheranderson / index.js
Last active November 6, 2017 11:57
Functions with Cognitive Services
var request = require('request');
var uuid = require('node-uuid');
/* Requires a Cognitive Services Text Analytics */
/* Be sure to install the request and node-uuid packages and add the "COG_URL" and "COG_KEY" App Settings before running */
module.exports = function(context, req) {
context.log('Node.js HTTP trigger function processed a request. RequestUri=%s', req.originalUrl);
// Make a call out to Cognitive Services