DEV Community

Lenut Ileni
Lenut Ileni

Posted on

Deploy with Azure Container Apps

Deploy Your App with Azure Container Apps (Beginner-Friendly Guide)

So you’ve built a cool app. It runs great on your machine. You’re proud.

But then someone says, “Cool, can you deploy it?” — and you suddenly start sweating.

Fear not! In this post, we’ll deploy your app to Azure Container Apps like pros (but with beginner energy).


What Are Azure Container Apps?

Azure Container Apps (ACA) is a fully managed serverless container service from Microsoft Azure.

In simple terms:

  • You bring your containerized app (Docker image).
  • Azure takes care of scaling, networking, and infrastructure management.
  • You only pay for what your container uses.

No need to set up VMs, load balancers, or wrestle with Kubernetes configurations.


Key Benefits

  • Serverless containers: Scale to zero when idle to save costs.
  • Simple deployment: Just az containerapp up and done.
  • Built-in scaling rules: Based on CPU, memory, or custom metrics.
  • Managed infrastructure: Azure handles the heavy lifting.
  • Language agnostic: If it runs in a container, it runs here.

Architecture Overview

Here’s the flow we’ll follow:

[Your App Code]
      ↓
   (Docker)
  Build Image
      ↓
 Push to Azure Container Registry (ACR)
      ↓
 Deploy to Azure Container Apps (ACA)
      ↓
 Access Your App in Browser
Enter fullscreen mode Exit fullscreen mode

In short:
Build → Push → Deploy → Access


Prerequisites

Before we start, make sure you have:


Step 1: Create a Container Registry (ACR)

We need a place to store our Docker image. That’s Azure Container Registry.

  1. Go to portal.azure.com
  2. Log in
  3. Search for “Container registries”
  4. Click + Create
  5. Fill out the form:
    • Subscription: your Azure subscription
    • Resource Group: create one (e.g., mygroup)
    • Registry Name: unique name (e.g., myregistry)
    • Location: choose something near you
    • SKU: Basic is fine for now
  6. Click Review + Create, then Create

You now have your own private Docker registry.


Step 2: Build Your Docker Image

Make sure your project has a Dockerfile in the root directory (there is an example of Dockerfile at the end of the post).

Then run this from your terminal:

docker build -t myapp:v1 .
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • docker build → builds a Docker image
  • -t myapp:v1 → tags your image with a name (myapp) and version (v1)
  • . → means the current directory (where your Dockerfile lives)

If it finishes without errors, you have a working image.


Step 3: Tag and Push Your Image to ACR

We’ll log in to Azure and push our image to the registry we just made.

1. Log in to Azure:

az login
Enter fullscreen mode Exit fullscreen mode

This opens a browser to sign in with your Azure account.

2. Log in to your registry:

az acr login --name myregistry
Enter fullscreen mode Exit fullscreen mode

This connects Docker with your Azure registry.

3. Tag your image for ACR:

docker tag myapp:v1 myregistry.azurecr.io/myapp:v1
Enter fullscreen mode Exit fullscreen mode

This tags your image so it points to your registry address.

4. Push the image:

docker push myregistry.azurecr.io/myapp:v1
Enter fullscreen mode Exit fullscreen mode

This uploads your image to your Azure Container Registry.


Step 4: Deploy to Azure Container Apps

Now the fun part — getting your app online.

Run this command:

az containerapp up   --name myapp   --resource-group mygroup   --image myregistry.azurecr.io/myapp:v1   --target-port 80   --ingress external
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • az containerapp up → creates and deploys a container app
  • --name myapp → name of your app
  • --resource-group mygroup → the resource group used earlier
  • --image ... → your container image from ACR
  • --target-port 80 → the internal port your app listens on
  • --ingress external → makes it accessible publicly

Azure will take a moment to deploy everything.


Step 5: Access Your App

When it’s done, you’ll see an output like:

Your app is deployed! URL: https://myapp.region.azurecontainerapps.io
Enter fullscreen mode Exit fullscreen mode

Copy that URL, open it in your browser, and your app is live.


Final Thoughts

You just:

  1. Built a Docker image
  2. Pushed it to Azure
  3. Deployed it to a live container app

All without managing servers or Kubernetes configurations.

Next steps:

  • Add CI/CD with GitHub Actions
  • Try scaling rules
  • Or simply enjoy your deployed application

Wrapping Up

Deploying with Azure Container Apps is one of the easiest ways to get your container running in the cloud — no servers, no clusters, no pain.

Now you can deploy your app confidently, and maybe even help someone else do the same.


Example: Dockerfile

# Use an official Node.js runtime as the base image
FROM node:18-alpine

# Set the working directory inside the container
WORKDIR /app

# Copy package files and install dependencies
COPY package*.json ./
RUN npm install --production

# Copy the rest of the application code
COPY . .

# Expose the port your app runs on
EXPOSE 80

# Define the command to start your app
CMD ["npm", "start"]
Enter fullscreen mode Exit fullscreen mode

Explanation

  • FROM node:18-alpine

    Starts with a lightweight Node.js base image.

  • WORKDIR /app

    Creates and switches to the /app directory inside the container.

  • COPY package*.json ./ and RUN npm install

    Copies your package files and installs dependencies before copying the rest — this helps Docker cache layers for faster rebuilds.

  • COPY . .

    Copies your application source code.

  • EXPOSE 80

    Tells Docker (and Azure) that your app listens on port 80.

  • CMD ["npm", "start"]

    Defines the command that runs when the container starts.

Top comments (0)