Deploying .NET Core Applications to Azure
Welcome to the discussion on best practices for deploying .NET Core applications to Azure. Below you'll find step‑by‑step guides, code samples, and community resources to help you get your services up and running smoothly.
Prerequisites
- Azure subscription (free tier works for testing)
- .NET 6 SDK or later
- Azure CLI installed
- Git for source control
Quick Deployment with Azure CLI
# Create a resource group
az group create --name MyResourceGroup --location eastus
# Create an App Service plan
az appservice plan create --name MyPlan --resource-group MyResourceGroup --sku B1 --is-linux
# Create a Web App
az webapp create --resource-group MyResourceGroup --plan MyPlan --name MyDotNetCoreApp --runtime "DOTNET|6.0"
# Deploy from local Git
git init
git remote add azure https://<username>@mydotnetcoreapp.scm.azurewebsites.net:443/mydotnetcoreapp.git
git add .
git commit -m "Initial commit"
git push azure master
Deploying with GitHub Actions
Automate your deployment pipeline with a simple workflow file.
name: Azure Web App CI/CD
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: '6.0.x'
- name: Build
run: dotnet publish -c Release -o ${{github.workspace}}/publish
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: MyDotNetCoreApp
slot-name: Production
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{github.workspace}}/publish
Additional Resources
Azure App Service Quickstart
Official Microsoft tutorial for deploying .NET Core to Azure App Service.
Azure Samples for .NET Core
Sample projects demonstrating various Azure services.
Azure DevOps Pipelines
Guide to setting up CI/CD pipelines with Azure DevOps.
No comments yet. Be the first to share your thoughts!