Azure Nodejs Demo Save Abandoned

Containerized Node.js Demo App for Azure App Service

Project README

azure-nodejs-demo

Containerized Node.js Demo App for Azure App Service.

Status Pipeline Website URL CDN Endpoint
Build Status dev.yaml azure-nodejs-demo-dev.azurewebsites.net nodejsdemo-dev.azureedge.net
Build Status production.yaml azure-nodejs-demo.azurewebsites.net nodejsdemo-prod.azureedge.net

Note: the dev.yaml pipeline generally "partially" fails because of security vulnerabilities found when running npm audit. Personally I allow the pipeline to continue and I'm not super concerned because these are only used for local development, e.g. watchers and hot reload.

The production.yaml pipeline only checks for non-development dependency vulnerabilities. And that's usually passing and green :)

Architecture

This demo leverages the Static Content Pattern in Cloud Architecture.

The images and CSS can be served from app itself or pulled from external host, e.g. CDN via ASSETS_BASE_URL environment variable.

Demo Architecture

Real-World CI/CD Pipelines

In real life you have more than one environment.

  • Azure Pipelines Best Practices

    • CI pipeline for feature branches and main
    • Deploy when pushing to main or production branches
    • See ./azure-pipelines for working pipelines and details
  • Asset Pipeline
    The included cd.yaml pipeline shows how to upload assets to Blob Storage and purge the Azure CDN cache as part of your deployment process.

  • CI/CD & Versioning
    Example versioning and promotion strategies leveraging git commit messages, git tags and package.json.

Azure Demo

Endpoints

Method Path Description
GET / root
GET /health health check endpoint
POST /webhooks/test accepts JSON and logs output

Healthcheck

This is an example healthcheck endpoint with standardized JSON per draft IETF standard

{
  "status": "pass",
  "version": "0.7.1",
  "details": {
    "uptime": {
      "component_type": "system",
      "observed_value": 24208698,
      "human_readable": "0 days, 6 hours, 43 minutes, 28 seconds",
      "observed_unit": "ms",
      "status": "pass",
      "time": "2021-04-12T11:45:32.508Z"
    },
    "env": {
      "WEBSITE_HOSTNAME": "azure-nodejs-demo-dev.azurewebsites.net",
      "WEBSITE_INSTANCE_ID": "03e7481d3d5ff1e67e297f158abd943ce8c8b920fa55dc7bf0565e86886404a8",
      "ASSETS_BASE_URL": "https://nodejsdemo-dev.azureedge.net"
    }
  }
}

Local Docker Development

Note: in local development, I tend to reference the image sha256. But for the docs, we'll leverage a custom tag azure-nodejs-demo to make this doc easier to follow.

Build Image

docker build --tag azure-nodejs-demo .

Run Image

To ensure it runs locally, we need to change the default NODE_ENV to disable https:// redirect. Otherwise browser throws insecure connection message and will not load page.

docker run -it -p 3000:3000 -e NODE_ENV=development azure-nodejs-demo

Target Platform (Edge Case)

In general, you should never publish local builds. In case you decide to do this (I was debugging some Azure Container Registry behavior ;-)) from an m1 Mac, you need to specify Linux as the target platform.

docker build --platform linux/amd64  .
Open Source Agenda is not affiliated with "Azure Nodejs Demo" Project. README Source: julie-ng/azure-nodejs-demo
Stars
66
Open Issues
6
Last Commit
1 month ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating