🏠 Home

Introduction

Having set up my development environment and integrated real-time stock data, I now need to deploy my application to Azure. In this post, I'll guide you through three key steps: containerizing my app with Docker for consistent behavior across environments, pushing the Docker image to Azure Container Registry for secure storage, and deploying via Azure App Service to make it cloud-accessible.

First, I'll containerize my application with Docker. This packages my app with its dependencies to ensure consistent operation anywhere, eliminating "works on my machine" problems. My Docker image will include all necessary components—code, runtime, tools, libraries, and settings.

After creating my Docker image, I'll push it to Azure Container Registry, allowing Azure to pull and run my application in an isolated environment. Docker uses OS-level virtualization to deliver software in containers, and Visual Studio provides simple tools for building, debugging, and deploying containerized applications. I can work with a single container or use orchestration tools for multiple services.

CandleWise Articles

CandleWise - A Portfolio Management App (Part 1): Environment Setup

CandleWise - Part 2: Integrating a third party API

CandleWise - Part 3: Deploying App to Azure

CandleWise - Part 4: Automating Deployment CI/CD

Docker support in Visual Studio

Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects. Visual Studio's Docker support has evolved across several releases to better meet customer needs. You can add two levels of Docker support to your project, with options varying by project type and Visual Studio version. For simpler needs, you can add basic Docker support to containerize a single project without orchestration. The more advanced level is container orchestration support, which adds files specific to your chosen orchestrator. Visual Studio 2022 features the Containers window, which allows you to view running containers, browse images, inspect environment variables, logs, port mappings, examine the filesystem, attach a debugger, or open a terminal inside the container environment.

Untitled

I added Docker support to the existing project by selecting Add > Docker Support in Solution Explorer. The Add > Docker Support and Add > Container Orchestrator Support commands are located on the right-click menu (or context menu) of the project node for an ASP.NET Core project in Solution Explorer. I selected Linux as the target OS.

The following changes were made:

The created Dockerfile resembled the following code: