Skip to content

Instantly share code, notes, and snippets.

View TsuyoshiUshio's full-sized avatar
🏠
Working from home

Tsuyoshi Ushio TsuyoshiUshio

🏠
Working from home
  • Microsoft
  • Kirkland
View GitHub Profile
@TsuyoshiUshio
TsuyoshiUshio / main.go
Created September 25, 2017 08:16
バイナリの挙動を調査した時のサンプル格闘コード
package main
import (
"bytes"
"encoding/binary"
"fmt"
"math/bits"
)
func main() {
@TsuyoshiUshio
TsuyoshiUshio / azuredeploy.json
Created October 13, 2017 14:32
Azure Container Instances deploy sample with two ports and ACR credential
$ cat azuredeploy.json
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
},
"resources": [
{
@TsuyoshiUshio
TsuyoshiUshio / FunctionSample.cs
Last active January 28, 2018 06:39
Event Grid article
[FunctionName("SomeFunc")]
public static async Task SomeFunc([EventGridTrigger] EventGridEvent eventGridEvent, TraceWriter log)
{
var data = JsonConvert.SerializeObject(eventGridEvent);
log.Info($"The SomeFunc : {data}");
}
@TsuyoshiUshio
TsuyoshiUshio / EventGridEvent.cs
Created January 28, 2018 06:44
Event Grid Event definition
public class EventGridEvent
{
public EventGridEvent();
[JsonProperty(PropertyName = "topic")]
public string Topic { get; set; }
[JsonProperty(PropertyName = "subject")]
public string Subject { get; set; }
[JsonProperty(PropertyName = "data")]
public JObject Data { get; set; }
@TsuyoshiUshio
TsuyoshiUshio / FunctionSample.cs
Last active January 28, 2018 07:05
Event Grid article
private static async Task sendEventGridMessageWithEventGridClientAsync(string topicHostName, string subject, object data)
{
var credentials = new Microsoft.Azure.EventGrid.Models.TopicCredentials(topicKey);
var client = new Microsoft.Azure.EventGrid.EventGridClient(credentials);
var eventGridEvent = new Microsoft.Azure.EventGrid.Models.EventGridEvent
{
Subject = subject,
EventType = "func-event",
EventTime = DateTime.UtcNow,
Id = Guid.NewGuid().ToString(),
@TsuyoshiUshio
TsuyoshiUshio / FunctionSample.cs
Created January 28, 2018 07:24
Event Grid article
[FunctionName("HttpHook")]
public static async Task<HttpResponseMessage> HttpHook([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
var body = await req.Content.ReadAsStringAsync();
log.Info($"HttpHook hooked: {body}");
return req.CreateResponse(HttpStatusCode.OK, new { greeting = "hello" });
}
@TsuyoshiUshio
TsuyoshiUshio / FunctionSample.cs
Created January 28, 2018 07:51
Event Grid article
[FunctionName("Merger")]
public static async Task Merge([EventGridTrigger] EventGridEvent eventGridEvent, TraceWriter log)
{
@TsuyoshiUshio
TsuyoshiUshio / AuthSample.cs
Last active October 12, 2018 22:54
Microsoft Graph Bindings (Azure Functions)
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;
@TsuyoshiUshio
TsuyoshiUshio / HttpTrigger.cs
Last active April 21, 2023 10:55
Azure Functions Unit Testing sample
[FunctionName(“HttpTrigger”)]
public async static Task<IActionResult> RunAsync([HttpTrigger(AuthorizationLevel.Function, “get”, “post”, Route = null)]HttpRequest req, TraceWriter log)
{
log.Info(“C# HTTP trigger function processed a request.”);
string name = req.Query[“name”];
string requestBody = new StreamReader(req.Body).ReadToEnd();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($”Hello, {name}”)
@TsuyoshiUshio
TsuyoshiUshio / HttpTriggerTest.cs
Created March 8, 2018 06:59
Azure Functions Untitesting Sample 2
[TestClass]
public class HttpTriggerTest : FunctionTestHelper.FunctionTest
{
[TestMethod]
public async Task Request_With_Query()