Deploy a Container App with Log Analytics

By Pulumi Team
Published
Updated

The Challenge

You need serverless container hosting on Azure with built-in monitoring and logging from the start. Container Apps provide automatic scaling and consumption-based pricing, while Log Analytics gives you centralized visibility into application behavior without configuring a separate logging pipeline.

What You'll Build

  • Container App running your application with a public HTTPS endpoint
  • Log Analytics workspace capturing all container logs
  • Container Registry storing your custom Docker image
  • Managed environment with integrated monitoring
  • Automatic scaling including scale-to-zero when idle

Neo Try This Prompt in Pulumi Neo

Run this prompt in Neo to deploy your infrastructure, or edit it to customize.

Best For

Use this prompt when you need serverless container hosting on Azure with built-in observability. Ideal for microservices, APIs, or web applications where you want automatic scaling and centralized logging without managing Kubernetes or configuring a separate monitoring stack.

Architecture Overview

This architecture uses Azure Container Apps to run your containerized application with minimal infrastructure management. Container Apps is a serverless container platform that handles scaling, networking, and TLS termination. You provide a container image, and the platform takes care of the rest, including scaling to zero when there is no traffic.

The key addition in this deployment is the Log Analytics workspace, which is integrated directly with the Container Apps managed environment. Every container in the environment automatically sends stdout, stderr, and system logs to Log Analytics. This means you get centralized logging without installing agents, configuring log forwarders, or setting up a separate observability stack.

A Container Registry stores your custom Docker image. The deployment builds the image from a local application directory, pushes it to the registry, and configures the Container App to pull from it. Registry credentials are stored as secrets within the Container App configuration, so the image pull process is secure and automatic.

Container Apps Managed Environment

The managed environment is the hosting boundary for your Container Apps. It provides shared networking, logging, and Dapr integration across all apps within it. The Log Analytics workspace is connected at the environment level, which means any Container App you add to this environment automatically gets logging without per-app configuration.

The environment also manages internal DNS and service discovery. If you deploy multiple Container Apps within the same environment, they can communicate by name without configuring network rules.

Log Analytics Integration

Log Analytics receives all container logs and system events from the managed environment. You can query these logs using KQL (Kusto Query Language) to debug issues, track request patterns, or monitor application health. Log queries can be saved, visualized in dashboards, or used as the basis for alerts.

This integration replaces the need to set up a separate logging pipeline (like an ELK stack or Fluentd configuration). For most containerized applications, the built-in Log Analytics integration provides sufficient observability for development and production use.

Container Registry

The Azure Container Registry stores and serves your Docker images. The deployment builds the image from your local code, tags it, and pushes it to the registry. Admin credentials are generated for the registry and stored as secrets in the Container App, allowing Fargate-style pull-and-deploy without manual authentication steps.

Common Customizations

  • Add Dapr sidecar: Enable Dapr on the Container App for built-in service invocation, state management, and pub/sub messaging between microservices.
  • Configure scaling rules: Set custom scaling rules based on HTTP concurrency, queue length, or custom metrics so the app scales at the right thresholds for your workload.
  • Add a custom domain: Configure a custom domain with managed TLS certificate instead of using the default Container Apps domain.
  • Deploy multiple apps in the same environment: Add additional Container Apps to the managed environment to share networking and logging while maintaining independent scaling and deployment.