Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Yoo justinyoo

View GitHub Profile
@justinyoo
justinyoo / 01-func-new-http-trigger.sh
Created Feb 21, 2021
Event-Driven KeyVault Secrets Rotation Management
View 01-func-new-http-trigger.sh
func new --name DisableSecretHttpTrigger --template HttpTrigger --language C#
@justinyoo
justinyoo / 01-keyvault-reference.txt
Last active Feb 16, 2021
KeyVault Secrets Rotation Management
View 01-keyvault-reference.txt
@Microsoft.KeyVault(SecretUri=https://<keyvault_name>.vault.azure.net/secrets/<secret_name>)
@justinyoo
justinyoo / 01-callback-1.cs
Last active Jan 20, 2021
WebSub to EventGrid via CloudEvents and Beyond
View 01-callback-1.cs
[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 Jan 18, 2021
Dev.To Article Publish Scheduler
View 01-scraping-article-id.cs
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 Jan 10, 2021
Dealing CloudEvents with Azure Functions for Azure EventGrid
View 01-dotnet-add-package.sh
dotnet add package Azure.Messaging.EventGrid --version 4.0.0-beta.4
@justinyoo
justinyoo / 01-az-logic-workflow-show.sh
Last active Jan 7, 2021
Provisioning EventGrid Subscription and LogicApp Handler Using Azure CLI
View 01-az-logic-workflow-show.sh
logicAppResourceId=$(az logic workflow show \
-g <resource_group_name> \
-n <logic_app_name> \
--query "id" -o tsv)
@justinyoo
justinyoo / 01-v1-legacy.cs
Created Nov 10, 2020
Open API Extension to Support Azure Functions v1
View 01-v1-legacy.cs
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 Nov 4, 2020
Deploying Azure Functions via GitHub Actions without Publish Profile
View 01-az-func-deploy.yaml
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'
@justinyoo
justinyoo / 01-get-inbound-ip-address.ps1
Last active Oct 26, 2020
Updating Azure DNS and SSL Certificate on Azure Functions via Github Actions
View 01-get-inbound-ip-address.ps1
$AppResourceGroupName = "[RESOURCE_GROUP_NAME_FOR_AZURE_FUNCTION_APP]"
AppName = "[NAME_OF_AZURE_FUNCTION_APP]"
$app = Get-AzResource `
-ResourceType Microsoft.Web/sites `
-ResourceGroupName $AppResourceGroupName `
-ResourceName $AppName
$newIp4Address = $app.Properties.inboundIpAddress
@justinyoo
justinyoo / 01-set-azwebapp.ps1
Last active Sep 30, 2020
3 Ways Mapping APEX Domains to Azure Functions
View 01-set-azwebapp.ps1
$resourceGroupName = "<RESOURCE_GROUP_NAME>"
$functionAppName = "<FUNCTION_APP_NAME>"
$domainName = "contoso.com"
Set-AzWebApp `
-ResourceGroupName $resourceGroupName `
-Name $functionAppName `
-HostNames @( $domainName, "$functionAppName.azurewebsites.net" )