Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Dockerize a Node.js App and Deploy It to Azure App Service

A practical path from Node.js Dockerfile to Azure App Service: use the provided PORT, deploy the exact tagged image, and diagnose common startup failures with logs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To deploy a Dockerized Node.js app to Azure App Service, make the server listen on process.env.PORT, build and tag the image, push it to a container registry, and configure App Service to run that exact image. A GitHub Actions workflow can automate the build, push, and deployment. If the container fails to start, check its startup command, runtime dependencies, port configuration, and logs before changing multiple settings.

Choose how Azure will build and run your app

There are two practical deployment paths, and the right one depends on whether you need to control the runtime environment.

As an Amazon Associate I earn from qualifying purchases.

Approach Who builds the deployable artifact? When it fits What you manage
Deploy app files with App Service build automation App Service can build the application from deployed files when build automation is enabled. See Microsoft’s GitHub Actions deployment guidance. When the built-in App Service runtime and build process meet the app’s needs. Ensure the correct source files and dependencies are deployed, and deliberately enable build automation.
Build and deploy a custom container image Your workflow builds the image before deployment. When you need to package the app’s runtime, dependencies, or OS-level requirements in an image. Build and tag the image, push it to a registry, configure registry access, and select the intended image in the App Service deployment step.

This walkthrough uses a custom container image. It gives the deployment a traceable image version, but requires a registry and image authentication. The workflow below uses Azure Container Registry; its exact configuration depends on your app and Azure setup.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the Node.js server listen on Azure’s port

Do not make the production server listen only on a hard-coded local port such as 3000. Microsoft says App Service sets PORT in the Node.js container and forwards incoming requests to that port: Configure Node.js Apps – Azure App Service.

const port = process.env.PORT || 3000;

app.listen(port, () => {
  console.log(`Server listening on ${port}`);
});

The fallback is useful for local development. In App Service, the server should use the port provided in PORT. For a custom container, also make sure its HTTP port configuration matches the port the application serves; App Service custom containers support one exposed HTTP port. See Configure a custom container for Azure App Service.

Build an image that starts the intended service

Your Dockerfile must match the app’s Node.js version, directory layout, package manager, and build process. There is no single correct Dockerfile for every Node app. Whatever the structure, include the production dependencies and application files the server needs, and make the final command launch the server in the foreground so the container remains running.

For example, the Dockerfile’s final command might be CMD ["npm", "start"] if the app defines a production start script. Confirm the script exists and launches the intended server; do not copy this command blindly if your project uses a different entry point. Microsoft’s startup troubleshooting guidance for Azure Container Apps likewise recommends verifying that the image’s start command launches the intended service: Troubleshoot start failures in Azure Container Apps.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build, push, and deploy the same image

A reliable deployment keeps the image identifier consistent from build through release. Tagging with the commit SHA gives each workflow run a traceable image name, rather than reusing an ambiguous tag such as latest. Microsoft’s example uses Azure Container Registry and a commit SHA: Deploy a custom container to App Service using GitHub Actions.

  1. Build and tag: Build the Docker image and tag it with the registry name, repository, and commit SHA.
  2. Push: Authenticate to your container registry and push that tagged image.
  3. Deploy: Configure the App Service deployment action with the fully qualified image name and tag that were just pushed.

Use the supported App Service deployment action in GitHub Actions, and store registry and Azure authentication credentials as repository secrets rather than committing them. Microsoft’s deployment guidance shows the action and secret-based configuration: Deploy by using GitHub Actions – Azure App Service. The deployment step must select the intended image explicitly; a successful image push alone does not mean App Service is running that image.

Handle compiled apps and deployment artifacts deliberately

For TypeScript and other compiled Node.js apps, ensure the deployable image or artifact contains the compiled output. Microsoft specifically advises building compiled apps in GitHub Actions before deploying their output folder with azure/webapps-deploy@v3: Deploy by Using GitHub Actions – Azure App Service.

With a custom container, arrange the Docker build so the compiled files are present in the final runtime image. With a file-based deployment, deploy the correct output directory, such as dist/ or build/, or intentionally enable App Service build automation. A workflow that deploys source files when the server expects compiled output can produce a deployment that completes but cannot start the app.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose the three common failure categories

The app listens on the wrong port

Symptom: The container appears to start, but App Service cannot deliver requests to the Node server. Check: Confirm the server reads process.env.PORT, then verify the custom-container HTTP port setting matches the port the app serves. App Service’s custom-container configuration supports one exposed HTTP port; do not assume a local development port is the right hosting port.

The container exits or never starts the server

Symptom: The container starts and stops, or the app never becomes available. Check: Verify the image’s CMD or entrypoint launches the intended production server and keeps it in the foreground. Then check that required production packages were installed and look for an application exception during startup. A missing script, dependency, or required runtime file can cause an early exit.

The deployed artifact or image is not the one the app needs

Symptom: The deployment step completes, but the expected app version or compiled app does not run. Check: For a container deployment, compare the fully qualified image name and tag in the workflow’s deploy step with the image that was built and pushed. For a compiled app, confirm the build ran and the resulting output was included in the deployed image or directory.

Use logs to identify the fault before changing settings

Enable container logging and inspect the output from the app and deployment before changing the port, image, and startup command all at once. Azure documents these CLI commands for App Service logging:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
az webapp log config --name <app-name> --resource-group <resource-group> --docker-container-logging filesystem
az webapp log tail --name <app-name> --resource-group <resource-group>

Replace the angle-bracketed values with your App Service name and resource group. The first command configures container logging to the filesystem; the second streams available logs. See Configure a custom container for Azure App Service and Enable diagnostic logging for apps in Azure App Service. Use the startup output to distinguish a port mismatch from a missing command, dependency, or runtime exception, then fix the identified cause and redeploy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.