Introduction
Modern applications are no longer built just to run on a single server—they are designed to be scalable, resilient, and cloud-native.
A cloud-native application:
Runs in the cloud (Azure)
Scales automatically
Uses managed services (DB, storage, messaging)
Is designed for high availability
In this guide, you'll build a real cloud-native ASP.NET Core Web API using Microsoft Azure.
What You Will Build
A simple Product Management API with:
ASP.NET Core Web API
Azure App Service (Hosting)
Azure SQL Database (Data Storage)
Azure Blob Storage (File Uploads)
Application Insights (Monitoring)
Prerequisites
.NET 8 SDK
Azure Account
Visual Studio / VS Code
Basic C# & ASP.NET Core knowledge
Step 1: Create ASP.NET Core Web API
dotnet new webapi -n CloudNativeApp
cd CloudNativeAppCreate Model
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public string ImageUrl { get; set; }
}Add DbContext
Install package:
dotnet add package Microsoft.EntityFrameworkCore.SqlServerpublic class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options) { }
public DbSet<Product> Products { get; set; }
}Step 2: Create Azure SQL Database
Steps in Azure Portal:
Create Azure SQL Database
Create Server + DB
Allow your IP in firewall
Add Connection String
In appsettings.json:
"ConnectionStrings": {
"DefaultConnection": "Server=tcp:yourserver.database.windows.net;Database=yourdb;User Id=admin;Password=yourpassword;"
}Configure in Program.cs
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));Step 3: Create API Controller
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
private readonly AppDbContext _context;
public ProductsController(AppDbContext context)
{
_context = context;
}
[HttpGet]
public async Task<IActionResult> Get()
{
return Ok(await _context.Products.ToListAsync());
}
[HttpPost]
public async Task<IActionResult> Create(Product product)
{
_context.Products.Add(product);
await _context.SaveChangesAsync();
return Ok(product);
}
}
Join the conversation! Your thoughts help the community grow.