Skip to content

Instantly share code, notes, and snippets.

@ahelland
ahelland / GithubWebhookDeployFile.csx
Created June 23, 2016 10:34
Azure Function for receiving a Github Webhook, and in turn running a WAWSDeploy of a specific file to an Azure Web App
#r "Microsoft.Web.Deployment.dll"
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Diagnostics;
using Microsoft.Web.Deployment;
using System.Collections.Generic;
using System.Collections.Specialized;
@ahelland
ahelland / RemoteCompile.cs
Created June 28, 2016 18:11
Snippet (based on a Universal App) for remote compiling and running .Net code using a Microsoft .Net API endpoint
using Newtonsoft.Json;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Web.Http;
using static System.Environment;
namespace RemoteCompile
{
@ahelland
ahelland / BenderToSlack.csx
Created July 12, 2016 07:48
Azure Function for sending a message through an incoming WebHook in Slack
#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http.Headers;
using System.Collections.Generic;
public static void Run(string input, TraceWriter log)
{
var statusMsg = "Bender says: Get up meatbag!";
@ahelland
ahelland / BenderFromSlack.csx
Last active June 23, 2019 23:45
Azure Function for receiving and processing an outbound WebHook from Slack
#r "Newtonsoft.Json"
#r "System.Web.Extensions"
#r "System.Web"
using System;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Linq;
@ahelland
ahelland / RandomTrigger.csx
Last active August 29, 2016 19:33
Azure Function running on a self-modifying random schedule
using System;
using System.IO;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
//Read current settings
string[] settings = File.ReadAllLines(@"D:\home\site\wwwroot\RandomTrigger\function.json");
var schedule = settings[6];
@ahelland
ahelland / ADFSSRS.csx
Created September 6, 2016 09:02
Azure Function returning word pairs
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}");
var responseMsg = String.Empty;
Random r = new Random();
int rInt = r.Next(0,4);
responseMsg = GetQuote(rInt);
@ahelland
ahelland / BenderToTeams.csx
Created November 15, 2016 19:57
Azure Function for sending a message through an incoming WebHook in Microsoft Teams
#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http.Headers;
using System.Collections.Generic;
public static void Run(string input, TraceWriter log)
{
var statusMsg = "Bender says: Get up meatbag!";
@ahelland
ahelland / MailDaemon.csx
Created December 9, 2016 18:27
Azure Function for sending a mail as a user after authenticating using the Password Grant flow
#r "Newtonsoft.Json"
using System;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json;
using static System.Environment;
using System.Collections.Generic;
public async static void Run(string input, TraceWriter log)
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace BenderPreCompiled
{
public class BenderDll
@ahelland
ahelland / HomeController.cs
Created March 29, 2017 09:31
Api Playground - HTTP
[HttpPost]
public async Task<IActionResult> Http(Code code)
{
string output = code.csx;
using (var client = new HttpClient())
{
var reqInput = code.csx;
var req = JsonConvert.DeserializeObject<HttpTestRequest>(reqInput);
var requestUrl = req.url;