Skip to content

Instantly share code, notes, and snippets.

View justinyoo's full-sized avatar

Justin Yoo justinyoo

View GitHub Profile
@justinyoo
justinyoo / 01-func-init.sh
Last active March 9, 2021 01:19
Enabling Open API on Azure Functions
func init MyFunctionApp --worker-runtime dotnet
@justinyoo
justinyoo / 01-counter.razor
Created March 7, 2021 22:37
Blazor Code-behind
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
@justinyoo
justinyoo / 01-func-new-http-trigger.sh
Created February 21, 2021 14:56
Event-Driven KeyVault Secrets Rotation Management
func new --name DisableSecretHttpTrigger --template HttpTrigger --language C#
@justinyoo
justinyoo / 01-keyvault-reference.txt
Last active February 16, 2021 22:24
KeyVault Secrets Rotation Management
@Microsoft.KeyVault(SecretUri=https://<keyvault_name>.vault.azure.net/secrets/<secret_name>)
@justinyoo
justinyoo / 01-callback-1.cs
Last active January 20, 2021 08:58
WebSub to EventGrid via CloudEvents and Beyond
[FunctionName("CallbackAsync")]
public async Task<IActionResult> CallbackAsync(
[HttpTrigger(AuthorizationLevel.Function, "GET", "POST", Route = "callback")] HttpRequest req,
ILogger log)
{
if (HttpMethods.IsGet(req.Method))
{
string challenge = req.Query["hub.challenge"];
var result = new ObjectResult(challenge) { StatusCode = 200 };
@justinyoo
justinyoo / 01-scraping-article-id.cs
Last active January 18, 2021 02:23
Dev.To Article Publish Scheduler
var pattern = "<div.+data-article-id=\"(\\d+)\"\\s*id=\"article-body\">";
var regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
var url = "https://dev.to/<username>/xxxx-****-temp-slug-xxxx?preview=xxxx";
var http = new HttpClient();
var html = await http.GetStringAsync(url);
var match = regex.Match(html);
var articleId = Convert.ToInt32(match.Groups[1].Value);
@justinyoo
justinyoo / 01-dotnet-add-package.sh
Last active January 10, 2021 11:41
Dealing CloudEvents with Azure Functions for Azure EventGrid
dotnet add package Azure.Messaging.EventGrid --version 4.0.0-beta.4
@justinyoo
justinyoo / 01-az-logic-workflow-show.sh
Last active July 29, 2022 14:00
Provisioning EventGrid Subscription and LogicApp Handler Using Azure CLI
logicAppResourceId=$(az logic workflow show \
-g <resource_group_name> \
-n <logic_app_name> \
--query "id" -o tsv)
@justinyoo
justinyoo / 01-v1-legacy.cs
Last active March 15, 2021 05:23
Open API Extension to Support Azure Functions v1
namespace MyV1LegacyFunctionApp
{
public static class LoremIpsumHttpTrigger
{
[FunctionName("LoremIpsumHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "lorem/ipsum")] HttpRequestMessage req,
ILogger log)
{
var content = new MyReturnObject();
@justinyoo
justinyoo / 01-az-func-deploy.yaml
Created November 4, 2020 07:07
Deploying Azure Functions via GitHub Actions without Publish Profile
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
...
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'