Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Azure Functions Sample to load nuget package, Octokit.
#r "Newtonsoft.Json"
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Reflection;
using Octokit;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
log.Verbose($"Webhook was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
if (data.owner == null || data.repository == null) {
return req.CreateResponse(HttpStatusCode.BadRequest, new {
error = "Please pass owner/repository properties in the input object"
string owner = data.owner;
string repository = data.repository;
var client = new GitHubClient(new ProductHeaderValue("AzureFunctions"));
var issues = await client.Repository.Commit.GetAll(owner, repository);
var commits = issues.Select(x => x.Commit.Tree.Sha).ToArray();
return req.CreateResponse(HttpStatusCode.OK, new {
CommitSha = commits,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.