Azure App Service – Complete Guide for .NET Lead
Official Documentation
Azure App Service Documentation
1. What is Azure App Service?
Azure App Service is a fully managed Platform as a Service (PaaS) that allows developers to deploy and host web applications, REST APIs, and mobile backends without managing servers or operating systems.
Instead of worrying about:
Installing Windows/Linux
IIS Configuration
OS Updates
Security Patches
Load Balancers
Scaling Infrastructure
You simply deploy your application, and Azure manages the infrastructure.
2. Traditional Hosting vs Azure App Service
Traditional Hosting
User
|
Internet
|
Load Balancer
|
Windows Server
|
IIS
|
ASP.NET Core API
|
SQL Server
You manage:
Server
IIS
Windows Updates
Firewall
Certificates
Scaling
Backup
Monitoring
Azure App Service
User
|
Internet
|
Azure App Service
|
ASP.NET Core API
|
Azure SQL Database
Azure manages:
Infrastructure
Operating System
IIS/Web Server
Security Patching
Load Balancing
Auto Scaling
Health Monitoring
You only manage your application.
3. Why Companies Use Azure App Service
Imagine an e-commerce company.
Components:
Angular Frontend
ASP.NET Core API
Azure SQL
Azure Service Bus
Azure Functions
Application Insights
The API is deployed to Azure App Service.
Architecture:
Users
|
Azure Front Door
|
Azure API Management
|
Azure App Service
|
+-------------+-------------+
| |
Azure SQL Azure Service Bus
| |
| Azure Functions
|
Application Insights
4. What Applications Can Be Hosted?
Azure App Service supports:
ASP.NET Core
.NET Framework
Node.js
Java
Python
PHP
Static Web Apps
Example:
Company Portal
HR Management
Banking API
Hospital Management
Insurance Portal
E-Commerce API
5. Real-Time Banking Example
Suppose ABC Bank has:
Mobile App
Internet Banking
ATM Services
Customer logs in.
Mobile App
|
v
Azure App Service
|
Authentication
|
Azure SQL
Thousands of users connect simultaneously.
Azure App Service automatically distributes incoming requests across available instances when scaled out.
6. App Service Architecture
Users
|
Internet
|
Azure Load Balancer
|
Azure App Service
+--------+--------+
| |
Instance 1 Instance 2
| |
+--------+--------+
|
Azure SQL Database
7. Important Features
Azure App Service provides:
Auto Scaling
Load Balancing
HTTPS
SSL Certificates
Custom Domains
Deployment Slots
Backup
Authentication
Logging
Monitoring
Managed Identity
VNet Integration
8. App Service Plan
One of the most common interview questions.
Many beginners think:
App Service = Server
That's incorrect.
The App Service runs inside an App Service Plan.
App Service Plan
|
+------ CPU
|
+------ Memory
|
+------ Region
|
+------ Pricing Tier
Think of it like renting an apartment.
The apartment is the App Service Plan.
Your application lives inside the apartment.
9. Multiple Apps in One Plan
App Service Plan
(4 CPU, 16 GB RAM)
| | |
HR API Order API Payment API
All applications share the resources of the App Service Plan.
10. Pricing Tiers
Common tiers include:
Free
Shared
Basic
Standard
Premium
Isolated
Interview point:
Development → Free/Basic
Production → Standard/Premium (depending on workload and requirements)
11. Deploying an ASP.NET Core API
Create the API:
dotnet new webapi
Run:
dotnet run
Publish:
dotnet publish -c Release
Deploy through:
Azure DevOps
GitHub Actions
Visual Studio
Azure CLI
ZIP Deployment
12. Example ASP.NET Core API
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
Controller:
[ApiController]
[Route("api/products")]
public class ProductsController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
return Ok(new[]
{
"Laptop",
"Mouse",
"Keyboard"
});
}
}
Once deployed:
https://companyapi.azurewebsites.net/api/products
13. Deployment Flow
Developer
|
Git Push
|
Azure DevOps
|
Build
|
Publish
|
Deploy
|
Azure App Service
14. Configuration
Never store secrets directly in code.
Bad:
string connection =
"Server=...;User=sa;Password=123";
Instead use configuration:
{
"ConnectionStrings": {
"DefaultConnection": ""
}
}
Then override values in App Service Application Settings or use Azure Key Vault for secrets.
15. Environment Variables
Azure App Service allows configuration such as:
Connection String
API URL
Storage Account
Service Bus
Application Insights
No code changes are required to switch environments when configuration is externalized.
16. Auto Scaling
Suppose your API receives:
Morning:
500 Users
Afternoon:
5,000 Users
Night:
30,000 Users
Instead of buying larger servers, Azure can scale based on configured rules.
Users
|
App Service
|
+----------+
| Instance |
+----------+
↓
High CPU
↓
+----------+
|Instance 1|
|Instance 2|
|Instance 3|
+----------+
17. Scale Up vs Scale Out
Scale Up (Vertical)
Increase resources of a single instance.
2 CPU
↓
8 CPU
Scale Out (Horizontal)
Increase the number of instances.
Instance 1
↓
Instance 1
Instance 2
Instance 3
Interview Question:
Which is better?
Answer:
Scale out generally provides better availability and elasticity for stateless web applications, while scale up can help when an application requires more resources per instance.
18. Deployment Slots
One of the best App Service features.
Suppose Production is live.
Production
Version 1
You want to deploy Version 2.
Instead of deploying directly:
Production
↓
Version 2
Use slots.
Production Slot
Version 1
Staging Slot
Version 2
Test Version 2.
If successful:
Swap
↓
Production
Version 2
Users experience little or no downtime during the swap.
19. Slot Swap
Before
Production → V1
Staging → V2
↓
Swap
↓
Production → V2
Staging → V1
If a rollback is required, you can swap again (assuming compatibility and deployment strategy support it).
20. Managed Identity
Instead of storing passwords:
App
↓
SQL Password
Use Managed Identity.
App Service
↓
Managed Identity
↓
Azure SQL
↓
Access Granted
No database password is stored in your application.
21. Authentication
App Service supports integration with identity providers.
Examples:
Microsoft Entra ID (Azure AD)
Microsoft Accounts
Google
GitHub (supported scenarios)
Other OpenID Connect/OAuth providers
This can simplify authentication for many applications.
22. Custom Domain
Instead of:
company.azurewebsites.net
Use:
api.company.com
along with an SSL certificate.
23. Logging
You can use ASP.NET Core logging:
_logger.LogInformation("Order Created");
Application Insights captures logs, requests, exceptions, dependencies, and traces for analysis.
24. Health Check
Suppose one instance becomes unhealthy.
Azure App Service can remove unhealthy instances from rotation when health checks are configured.
Load Balancer
↓
Instance 1
Instance 2
Instance 3
↓
Instance 2 unhealthy
↓
Traffic goes to healthy instances
25. Real-Time Insurance Example
Customer submits:
Claim
↓
App Service
↓
Azure SQL
↓
Service Bus
↓
Notification Service
If traffic suddenly increases after a natural disaster:
Azure App Service can scale based on configured policies while Azure Monitor and Application Insights help you observe performance.
26. Security Best Practices
Use HTTPS only
Store secrets in Azure Key Vault
Use Managed Identity
Restrict network access where appropriate
Enable authentication/authorization
Keep dependencies updated
Monitor with Azure Monitor and Application Insights
27. Interview Questions
Basic
What is Azure App Service?
What is PaaS?
Difference between App Service and Virtual Machine?
What applications can App Service host?
What is an App Service Plan?
What is deployment?
What is auto scaling?
What is slot deployment?
What is Managed Identity?
What is a custom domain?
Intermediate
Difference between Scale Up and Scale Out?
Explain deployment slots.
How does App Service communicate with Azure SQL?
How do you secure secrets?
How do you monitor App Service?
How do you configure Application Settings?
What is VNet Integration?
How do you enable authentication?
How does zero-downtime deployment work?
What are App Service Plans?
Lead-Level
Design a highly available App Service architecture.
How would you deploy microservices?
How would you secure production APIs?
How would you implement CI/CD using Azure DevOps?
How would you monitor production?
How would you troubleshoot a slow App Service?
How would you design disaster recovery?
How would you integrate App Service with Service Bus and Azure Functions?
When would you choose App Service over AKS?
What production best practices would you follow?
28. Lead-Level Interview Answer
If an interviewer asks:
"Explain how you have used Azure App Service in your project."
A strong answer is:
"In our microservices-based .NET solution, we hosted ASP.NET Core Web APIs on Azure App Service. Azure DevOps pipelines automatically built and deployed the applications. Configuration values were managed through App Service settings and Azure Key Vault. Authentication was integrated with Microsoft Entra ID, and Managed Identity was used to securely access Azure SQL and other Azure resources without storing credentials in code. We used deployment slots for zero-downtime releases, auto-scale rules based on CPU and HTTP traffic, and monitored the application using Application Insights and Azure Monitor. The APIs also communicated asynchronously with Azure Service Bus to improve scalability and resilience."
This answer demonstrates not only knowledge of Azure App Service but also how it fits into a modern production architecture.

No comments:
Post a Comment