Skip to content

Instantly share code, notes, and snippets.

Tips for speed up Oryx remote build/deploy time for App Service on Linux for Node.js

Cache node_modules for each hash of package-lock.json, Node version and NPM version

/home/site/deploy_cache/node_modules-${md5 hash_of_package_lock.json}-node${NODE_VERSION}-npm${NPM_VERSION}.tar.gz

graph TB;
  Start([Start]);
  Start-->CheckLockVersion{if package-lock.json changed};
@georgeOsdDev
georgeOsdDev / AppServiceCertificateExpirationTimeCheck.kql
Created January 5, 2023 01:09
App Service Certificate Expiration time check by Azure Resource Graph
// https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview
resources
| where type == "microsoft.certificateregistration/certificateorders"
| where subscriptionId == "<SubscriptionId>"
| project id, resourceGroup, name, properties["distinguishedName"] ,properties["provisioningState"], properties["expirationTime"],properties["autoRenew"],properties
@georgeOsdDev
georgeOsdDev / get container id
Created December 10, 2022 22:33
App Service on Linux: Get container id from inside container
CONTAINER_ID=$(cat /proc/self/cgroup | grep docker | grep $WEBSITE_SITE_NAME | head -1| rev | cut -d "/" -f 1 | rev)
@georgeOsdDev
georgeOsdDev / postdeploy.sh
Created November 25, 2022 17:25
How to use custom Node version on Azure App Service Linux
#!/bin/bash
# Usage
# 1.Save this file to project root directory
# 2.Defaul POST_BUILD_COMMAND in appsettings
# https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux#customize-build-automation
# > az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings POST_BUILD_COMMAND="postbuild.sh"
# 3.Enable remote build
# https://github.com/projectkudu/kudu/wiki/Configurable-settings#enabledisable-build-actions
# 4.Update start script to use LTS binary instead of default Node.
# LTS binary path is defined in /home/site/lts_node_path
@georgeOsdDev
georgeOsdDev / test.yaml
Created August 17, 2022 14:17
artifact check
name: artifact check
on:
push:
branches:
- main
workflow_dispatch:
jobs:
test:
@georgeOsdDev
georgeOsdDev / HttpTrigger1.cs
Last active January 14, 2022 02:49
Use resx from Azure Function
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
public class HttpTrigger1
{
@georgeOsdDev
georgeOsdDev / shell.sh
Created December 6, 2021 07:27
Get all storages used by azure function app
#!/bin/bash -l
set -Ceu
ids=`az functionapp list --query '[].id' -o tsv`
for id in $ids; do
read rg name <<< $(echo $id | awk -F '/' '{print $5, $9}')
storage=$(az functionapp config appsettings list -g $rg -n $name --query "[?name == 'AzureWebJobsStorage'].value" -o tsv | awk -F ';' '{for(i = 1; i <= NF; i++){printf $i "\n"}}' | grep AccountName | awk -F '=' '{print $2}')
echo $rg, $name, $storage
done
@georgeOsdDev
georgeOsdDev / shell.sh
Created December 6, 2021 07:01
Get storage account used by function
# export myRG=<resource group>
# export myFunctionApp=<function app>
az functionapp config appsettings list -g $myRG -n $myFunctionApp --query "[?name == 'AzureWebJobsStorage'].value" -o tsv | awk -F ';' '{for(i = 1; i <= NF; i++){printf $i "\n"}}' | grep AccountName | awk -F '=' '{print $2}'
@georgeOsdDev
georgeOsdDev / viewer.html
Created March 12, 2020 07:11
View images from `S3:bucket-name/yyyy/mm/dd/hh/mm/ss/file.png`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.638.0.min.js"></script>
</head>
<body>
S3Bucket: <input class='field' id='s3bucket' type='text' value='xxxx' required/></br>
accessKeyId: <input class='field' id='accessKeyId' type='text' value='yyyy' required/></br>
@georgeOsdDev
georgeOsdDev / Boot.scala
Created February 23, 2018 09:15
Xitrum websocket connection issue
package quickstart
import xitrum.Server
object Boot {
def main(args: Array[String]) {
Server.start()
Server.stopAtShutdown()
}
}