Thursday, November 6, 2025

thumbnail

Deploying Full Stack .NET Applications on Azure

 ๐Ÿงฑ 1. Typical Full Stack .NET Architecture on Azure


A Full Stack .NET application usually has three layers:


Layer Technology Azure Service

Frontend React, Angular, or Blazor Azure App Service (Web App) or Azure Static Web Apps

Backend / API ASP.NET Core Web API Azure App Service (API App), Azure Kubernetes Service (AKS), or Azure Functions (Serverless)

Database / Data Layer SQL Server, Cosmos DB, Blob Storage Azure SQL Database, Azure Cosmos DB, Azure Storage


Optionally, you can integrate Azure DevOps, GitHub Actions, and Application Insights for CI/CD, versioning, and monitoring.


⚙️ 2. Preparing Your Full Stack .NET Application


Assume your project looks like this:


/FullStackApp

├── /ClientApp      → React, Angular, or Blazor WebAssembly (Frontend)

├── /ServerApp      → ASP.NET Core API (Backend)

└── /Shared         → Shared DTOs or libraries


Build Locally


Use Visual Studio / VS Code to build both frontend and backend.


Test API endpoints and frontend UI locally before deploying.


Command examples:


dotnet build

dotnet test

dotnet publish -c Release


☁️ 3. Choosing the Right Azure Hosting Services


You have several options depending on your needs:


Scenario Recommended Azure Service

Small/Medium app with minimal ops Azure App Service (PaaS)

Microservices or containerized app Azure Kubernetes Service (AKS)

Serverless architecture Azure Functions

Static frontend + API backend Azure Static Web Apps + Azure Functions / API App

๐Ÿš€ 4. Deploying Backend (ASP.NET Core API)

Option 1: Deploy to Azure App Service


Azure App Service is the easiest way to host .NET APIs.


Steps:


Publish directly from Visual Studio


Right-click on your API project → Publish → Azure → Azure App Service.


Choose or create a Resource Group and App Service Plan.


Click Publish → Visual Studio handles the deployment.


Using Azure CLI


az login

az webapp up --name mydotnetapi --resource-group MyResourceGroup --runtime "DOTNETCORE:8.0"



Configure Environment Variables


az webapp config appsettings set --name mydotnetapi --resource-group MyResourceGroup --settings "ASPNETCORE_ENVIRONMENT=Production"



✅ The API is now live on:

https://mydotnetapi.azurewebsites.net


Option 2: Deploy as Containers (AKS or Azure Container Apps)


If your .NET backend runs in Docker:


Dockerize the API


FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base

WORKDIR /app

COPY . .

ENTRYPOINT ["dotnet", "ServerApp.dll"]



Push to Azure Container Registry (ACR)


az acr create --name myacr --resource-group MyResourceGroup --sku Basic

az acr login --name myacr

docker tag serverapp myacr.azurecr.io/serverapp:v1

docker push myacr.azurecr.io/serverapp:v1



Deploy to AKS


az aks create --resource-group MyResourceGroup --name myAKS --node-count 2 --enable-addons monitoring --generate-ssh-keys

kubectl apply -f deployment.yaml


๐ŸŽจ 5. Deploying the Frontend (React, Angular, or Blazor)

Option 1: Azure Static Web Apps (Best for React/Angular)


Azure Static Web Apps automatically builds and deploys your frontend and backend (if using Azure Functions).


Push code to GitHub


In the Azure Portal → Create Resource → Static Web App


Link your GitHub repository.


Choose:


App location: /ClientApp


API location: /ServerApp


Build output: build or dist


Azure automatically:


Builds the frontend via GitHub Actions.


Deploys it globally with CDN caching.


Connects your backend API.


Option 2: Azure App Service for Full Stack App


If you want both backend and frontend hosted in one App Service:


Publish frontend build files into a wwwroot folder in the API project.


Modify your Program.cs in .NET API to serve static files:


app.UseDefaultFiles();

app.UseStaticFiles();



Deploy via Visual Studio or Azure CLI.


๐Ÿงฉ 6. Setting Up the Database

Option 1: Azure SQL Database


For relational data and Entity Framework Core:


Create an Azure SQL Database:


az sql server create --name mydbserver --resource-group MyResourceGroup --location eastus --admin-user adminuser --admin-password P@ssword123!

az sql db create --resource-group MyResourceGroup --server mydbserver --name myappdb --service-objective S0



Update connection string in Azure App Service:


az webapp config connection-string set --resource-group MyResourceGroup \

--name mydotnetapi --settings "DefaultConnection=Server=tcp:mydbserver.database.windows.net;Database=myappdb;User ID=adminuser;Password=P@ssword123!;" \

--connection-string-type SQLAzure


Option 2: Azure Cosmos DB


If you need NoSQL (document-based) storage:


az cosmosdb create --name mycosmos --resource-group MyResourceGroup --kind MongoDB



Use the connection string in your .NET app.


๐Ÿ”„ 7. Continuous Integration / Continuous Deployment (CI/CD)

Option 1: Azure DevOps Pipelines


Create a new Pipeline → connect to your Git repository.


Add build and release stages:


Build Stage: Restore, build, and test .NET code.


Release Stage: Deploy to Azure App Service using the Azure WebApp Deploy task.


Example YAML:


trigger:

- main


pool:

  vmImage: 'windows-latest'


steps:

- task: UseDotNet@2

  inputs:

    packageType: 'sdk'

    version: '8.x'


- script: dotnet build --configuration Release

  displayName: 'Build Project'


- task: AzureWebApp@1

  inputs:

    azureSubscription: '<ServiceConnection>'

    appName: 'mydotnetapi'

    package: '$(System.DefaultWorkingDirectory)/**/*.zip'


Option 2: GitHub Actions


Add .github/workflows/deploy.yml:


name: Deploy .NET to Azure

on:

  push:

    branches: [ "main" ]


jobs:

  build-and-deploy:

    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v3

      - name: Setup .NET

        uses: actions/setup-dotnet@v3

        with:

          dotnet-version: '8.x'

      - name: Publish

        run: dotnet publish -c Release -o ./publish

      - name: Deploy to Azure Web App

        uses: azure/webapps-deploy@v3

        with:

          app-name: mydotnetapi

          publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

          package: ./publish


๐Ÿ“Š 8. Monitoring and Logging


Azure Application Insights: Automatically integrates with .NET applications.


builder.Services.AddApplicationInsightsTelemetry();



Provides:


Request and dependency tracking


Error logs


Performance metrics


Distributed tracing


You can view metrics in the Azure Portal → Application Insights.


๐Ÿ” 9. Security Best Practices


Use Managed Identity instead of storing credentials.


Enable HTTPS Only in App Service settings.


Store secrets in Azure Key Vault.


Restrict public database access (use Private Endpoints).


Enable App Service Authentication (e.g., Azure AD, Microsoft Entra ID).


⚡ 10. Scaling and Optimization


Scaling: Enable Auto-scaling in App Service based on CPU or requests.


Caching: Use Azure Front Door or Azure CDN for frontend.


Queueing: Use Azure Service Bus or Storage Queues for background processing.


Performance Monitoring: Application Insights + Azure Monitor.


✅ Summary

Component Azure Service Purpose

Frontend (React/Blazor) Static Web Apps / App Service Host UI

Backend (ASP.NET Core API) App Service / AKS / Functions Serve business logic

Database Azure SQL / Cosmos DB Store data

CI/CD Azure DevOps / GitHub Actions Automate deployment

Monitoring Application Insights Track health and performance

Security Key Vault, Managed Identity Protect credentials and data

๐Ÿš€ Bottom Line


Deploying a Full Stack .NET application on Azure is smooth, especially if you:


Use Azure App Service (for simplicity and scalability),


Azure SQL Database (for data),


Automate via Azure DevOps or GitHub Actions, and


Monitor with Application Insights.


You get a fully managed, end-to-end, secure, and scalable .NET environment — ideal for modern DevOps workflows.

Learn Dot Net Course in Hyderabad

Read More

Cloud and Deployment in Dot Net

Continuous Integration and Continuous Deployment (CI/CD) in .NET

Using Azure Services for Full Stack .NET Development

Integrating External APIs in Full Stack .NET Applications

Visit Our Quality Thought Institute in Hyderabad

Get Directions 


Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

About

Search This Blog

Powered by Blogger.

Blog Archive