Code Examples
Deploy a .NET Web App
az webapp create \
--resource-group MyResourceGroup \
--plan MyAppServicePlan \
--name MyDotNetApp \
--runtime "DOTNETCORE|6.0"
New-AzWebApp `
-ResourceGroupName "MyResourceGroup" `
-Location "EastUS" `
-AppServicePlan "MyAppServicePlan" `
-Name "MyDotNetApp" `
-Runtime "DOTNETCORE|6.0"
Node.js Hello World
az webapp up \
--resource-group MyResourceGroup \
--name MyNodeApp \
--runtime "NODE|18-lts"
name: Deploy Node.js app
on:
push:
branches: [ main ]
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: MyNodeApp
slot-name: production
Python Flask App
az webapp up \
--resource-group MyResourceGroup \
--name MyFlaskApp \
--runtime "PYTHON|3.11"
FROM python:3.11-slim
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]
Java Spring Boot
az webapp create \
--resource-group MyResourceGroup \
--plan MyAppServicePlan \
--name MySpringApp \
--runtime "JAVA|17"
17
3.2.0
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-maven-plugin
Static Site (HTML/CSS/JS)
az webapp up \
--resource-group MyResourceGroup \
--name MyStaticSite \
--runtime "HTML"
name: Deploy static site
on:
push:
branches: [ main ]
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Azure login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Static Web Apps
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/"