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
@christopheranderson
christopheranderson / omg.cs
Last active November 15, 2017 00:28
Why would I do this?
using System;
using System.Threading.Tasks;
using EdgeJs;
class Program
{
public static async Task Start()
{
var func = Edge.Func(@"
return function (data, callback) {
@christopheranderson
christopheranderson / readme.md
Last active November 21, 2017 06:41
Use Functions in Visual Studio

How to use Functions in Visual Studio

This is super hacky, but just wanted to leave the notes somewhere reusable that isn't official documentation. This isn't "recommended", but it is possible. :)

  1. Create your Functions via the Azure Functions portal UX is the easiest way. Otherwise, just follow the file format rules on the Azure Functions located here.
  2. Download them via your scm site - {function app name}.scm.azurewebsites.net -> DebugConsole -> cd ./site -> click on the "download" button for wwwroot
  3. Open Visual Studio, create a new Website, choose your unzipped wwwroot folder.
  4. Now you should see all your Functions in a directory in your Visual Studio. You can edit them here. etc.
  5. To Publish - Just right-click->publish on the project, choose an existing Web App (even though it's a function app, it speaks Web App apis, so it shows up here). Then publish with your changes. If might fail, just click on the "
@christopheranderson
christopheranderson / index.js
Created March 14, 2019 18:38
ChangeFeed hasMoreResults issue
//@ts-check
const cosmos = require("@azure/cosmos");
const {items} = require("./sampleItems");
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
const {CosmosClient} = cosmos;
const endpoint = process.env.COSMOS_ENDPOINT;
const key = process.env.COSMOS_KEY;
@christopheranderson
christopheranderson / upsert-test.js
Created October 9, 2019 23:21
Test using upsert with condition on non-existing always succeeds
//@ts-check
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
const { CosmosClient } = require("@azure/cosmos");
const client = new CosmosClient({
endpoint: "https://localhost:8081",
key:
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
});
@christopheranderson
christopheranderson / index.ts
Created August 28, 2018 02:10
create-hmac typescript default import
import createHmac from "create-hmac";
const hmac = createHmac("sha256", "hello world").update("I love cupcakes").digest("hex");
console.log(hmac);
@christopheranderson
christopheranderson / azuredeploy.json
Created February 10, 2017 08:54
Function App ARM template with MSDeploy
{
"$schema": "http://schemas.management.azure.com/schemas/2015-01-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
@christopheranderson
christopheranderson / body.json
Created January 9, 2018 23:27
Example context object for Azure Functions
{
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
"executionContext": {
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
"functionName": "hello",
"functionDirectory": "C:\\workspace\\temp\\contextjs\\hello"
},
"log": "[FUNCTION]",
"bindingData": {
"invocationId": "a3ea24b8-d262-41d0-a57b-f6a207ade9c2",
@christopheranderson
christopheranderson / FunctionBotRun.csx
Last active October 22, 2022 17:09 — forked from ahelland/FunctionBotRun.csx
An Azure Function implementing the Microsoft Bot Framework to return random quotes
using System.Net;
using Microsoft.Bot.Connector;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Verbose($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}");
var msg = await req.Content.ReadAsAsync<Message>();