A Complete Guide for Developers
Introduction
Building a modern web application using ASP.NET Core as the backend and Angular as the frontend is a popular approach. Once the application is ready, the next crucial step is deployment to a reliable cloud platform. Microsoft Azure provides a rich ecosystem for hosting full-stack applications with features like:
App Services for hosting web apps
Azure SQL Database for relational data
Application Insights for monitoring
DevOps pipelines for CI/CD
This article covers a step-by-step guide to deploy an ASP.NET Core + Angular application to Azure with production-ready practices.
1. Understanding the Architecture
A typical setup for ASP.NET Core + Angular apps looks like this:
[Angular SPA] <---> [ASP.NET Core API] <---> [Database (SQL Server/Azure SQL)]
Key points
Angular is a Single Page Application (SPA) built with
ng buildASP.NET Core serves the Angular static files and provides APIs
Azure App Service hosts the combined backend and frontend
Azure SQL Database stores application data
2. Preparing the Application
2.1 Angular Configuration
Set the base href in
angular.json:
"projects": {
"my-app": {
"architect": {
"build": {
"options": {
"outputPath": "wwwroot",
"baseHref": "/"
}
}
}
}
}
Build the Angular project for production:
ng build --configuration production
This generates static files in dist/my-app. In an ASP.NET Core project, these are served from the wwwroot folder.
2.2 ASP.NET Core Configuration
Install
Microsoft.AspNetCore.SpaServices.Extensions:
dotnet add package Microsoft.AspNetCore.SpaServices.Extensions
Configure
Startup.csto serve Angular:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
}
});
}
ClientAppfolder contains the Angular projectIn production,
wwwroothosts the compiled Angular files
3. Setting Up Azure Environment
3.1 Azure App Service
Log in to Azure Portal
Create a Resource Group for the app
Create an App Service:
Runtime: .NET 7 / 8 (match your ASP.NET Core version)
Region: closest to your users
SKU: Standard or Premium for production
3.2 Azure SQL Database (Optional)
Create a managed SQL database
Configure firewall rules for access from App Service
Update
appsettings.jsonconnection string:
"ConnectionStrings": {
"DefaultConnection": "Server=tcp:<your-server>.database.windows.net,1433;Initial Catalog=MyDatabase;User ID=<username>;Password=<password>;Encrypt=True;"
}
4. Deployment Strategies
There are multiple ways to deploy ASP.NET Core + Angular apps to Azure:

Join the conversation! Your thoughts help the community grow.