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
Step 1: Create ASP.NET Core Web API
dotnet new webapi -n CloudNativeApp
cd CloudNativeApp
Create 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.SqlServer
public 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:
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);
}
}
Step 4: Add Azure Blob Storage (File Upload)
Install package:
dotnet add package Azure.Storage.Blobs
Blob Service
public class BlobService
{
private readonly string _connectionString = "your_blob_connection";
public async Task<string> UploadAsync(IFormFile file)
{
var container = new BlobContainerClient(_connectionString, "products");
await container.CreateIfNotExistsAsync();
var blob = container.GetBlobClient(file.FileName);
using var stream = file.OpenReadStream();
await blob.UploadAsync(stream, overwrite: true);
return blob.Uri.ToString();
}
}
Use in Controller
[HttpPost("upload")]
public async Task<IActionResult> Upload(IFormFile file)
{
var url = await _blobService.UploadAsync(file);
return Ok(url);
}
Step 5: Add Application Insights (Monitoring)
In Azure:
Install
C#dotnet add package Microsoft.ApplicationInsights.AspNetCore
builder.Services.AddApplicationInsightsTelemetry();
Now you can track:
Requests
Failures
Performance
Step 6: Deploy to Azure App Service
Method: Visual Studio / CLI
CLI Deployment:
az login
az webapp up --name your-app-name --resource-group your-rg --runtime "DOTNET:8"
After Deployment
You'll get:
https://your-app-name.azurewebsites.net
Test:
GET /api/products
POST /api/products
Step 7: Make It Cloud-Native (Important )
To make your app truly cloud-native, apply:
1. Environment-Based Configuration
builder.Configuration.AddEnvironmentVariables();
Store secrets in Azure (not in code)
2. Use Azure Key Vault (Optional Advanced)
3. Enable Auto Scaling
In Azure App Service:
4. Logging & Monitoring
Use:
Application Insights
Logs
Alerts
5. Stateless Design
Final Architecture
Client → App Service → ASP.NET Core API
↓
Azure SQL Database
↓
Azure Blob Storage
↓
Application Insights (Monitoring)
Real-World Enhancements
You can extend this app with:
Authentication (Azure AD / JWT)
Caching (Azure Redis)
Messaging (Azure Service Bus)
Docker + AKS (microservices)
Interview Questions You Can Answer Now
What is a cloud-native app?
How does Azure App Service scale?
How do you secure connection strings?
Blob Storage vs SQL Storage?
How to monitor production apps?
Conclusion
You've successfully built your first cloud-native ASP.NET Core app on Azure
You now understand:
Next Step (Recommended)
Upgrade this project to: