Skip to content

Instantly share code, notes, and snippets.

View justinyoo's full-sized avatar

Justin Yoo justinyoo

View GitHub Profile
@justinyoo
justinyoo / 01-run-byte-array.cs
Last active October 26, 2021 06:34
Transmitting Binary Data via OpenAPI on Azure Functions
public static class BinaryDataHttpTrigger
{
[FunctionName(nameof(BinaryDataHttpTrigger.RunByteArray))]
[OpenApiOperation(operationId: "run.bytearray", tags: new[] { "bytearray" }, ...)]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiRequestBody(contentType: "text/plain", bodyType: typeof(byte[]), ...)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "image/png", bodyType: typeof(byte[]), ...)]
@justinyoo
justinyoo / 01-apikey-in-query-auth-flow-httptrigger.cs
Last active February 9, 2024 16:06
Securing Azure Functions Endpoints via OpenAPI Auth
public static class ApiKeyInQueryAuthFlowHttpTrigger
{
[FunctionName(nameof(ApiKeyInQueryAuthFlowHttpTrigger))]
[OpenApiOperation(operationId: "apikey.query", tags: new[] { "apikey" }, Summary = "API Key authentication code flow via querystring", Description = "This shows the API Key authentication code flow via querystring", Visibility = OpenApiVisibilityType.Important)]
[OpenApiSecurity("apikeyquery_auth",
SecuritySchemeType.ApiKey,
In = OpenApiSecurityLocationType.Query,
Name = "code")]
@justinyoo
justinyoo / 01-auth-login-aad.txt
Created September 12, 2021 07:51
Accessing MSGraph from Blazor WASM Running on ASWA
https://<azure_static_webapp>.azurestaticapps.net/.auth/login/aad
public static class DefaultHttpTrigger
{
[FunctionName("DefaultHttpTrigger")]
[OpenApiOperation(operationId: "greeting", tags: new[] { "greeting" }, Summary = "Greetings", Description = "This shows a welcome message.", Visibility = OpenApiVisibilityType.Important)]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiParameter("name", Type = typeof(string), In = ParameterLocation.Query, Visibility = OpenApiVisibilityType.Important)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Greeting), Summary = "The response", Description = "This returns the response")]
public static async Task<IActionResult> Run(
@justinyoo
justinyoo / 01-on-team-page-requested-1.yaml
Created August 20, 2021 09:51
Running Hackathon by Yourself with GitHub Actions, Microsoft 365 and Power Platform
name: On Team Page Requested
on:
workflow_dispatch:
inputs:
teamName:
description: The name of team
required: true
default: Team_HackaLearn
content:
@justinyoo
justinyoo / 00-program.cs
Created August 13, 2021 12:28
Azure Functions OpenAPI on .NET 5
public static void Main()
{
var host = new HostBuilder()
// 👇👇👇👇👇 Remove this line below 👇👇👇👇👇
.ConfigureFunctionsWorkerDefaults()
// 👆👆👆👆👆 Remove this line above 👆👆👆👆👆
.Build();
host.Run();
}
@justinyoo
justinyoo / 01-create-routine-01.cs
Created May 19, 2021 12:58
Tracing End-to-End Data from Power Apps to Azure Cosmos DB
public async Task<IActionResult> CreateRoutineAsync(
[HttpTrigger(AuthorizationLevel.Function, HttpVerbs.Post, Route = "routines")] HttpRequest req,
ExecutionContext context,
ILogger log)
{
var request = await req.ToRequestMessageAsync<RoutineRequestMessage>().ConfigureAwait(false);
var @interface = request.Interface;
var correlationId = request.CorrelationId;
var spanId = request.SpanId;
@justinyoo
justinyoo / 01-create-routine.cs
Created May 11, 2021 15:10
Developing Power Apps in Fusion Teams
// Decorators for OpenAPI
[OpenApiOperation(operationId: "CreateRoutine", tags: new[] { "publisher", "routine" }, Summary = "Create a new routine", Description = "This creates a new routine", Visibility = OpenApiVisibilityType.Important)]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "x-functions-key", In = OpenApiSecurityLocationType.Header, Description = "API key to execute this endpoint")]
[OpenApiRequestBody(contentType: ContentTypes.ApplicationJson, bodyType: typeof(RoutineRequestMessage), Required = true, Example = typeof(RoutineRequestMessageExample), Description = "The request message payload for a routine")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: ContentTypes.ApplicationJson, bodyType: typeof(RoutineResponseMessage), Example = typeof(RoutineResponseMessageExample), Summary = "200 response", Description = "This returns the response of 'OK'")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.InternalServerError, contentType: ContentTypes.Application
@justinyoo
justinyoo / 01-bicep-build.sh
Created April 21, 2021 08:43
Bicep Refreshed
# Bicep CLI
bicep build azuredeploy.bicep
# Azure CLI
az bicep build --file azuredeploy.bicep
@justinyoo
justinyoo / 01-install-azuread.ps1
Last active July 6, 2021 07:49
Automatic Provisioning Power Platform Hands-on-Labs Environment
Install-Module -Name AzureAD `
-Scope AllUsers -Repository PSGallery `
-Force -AllowClobber