We’ll cover:
- Creating an Azure Static Web App
- Configuring deployment credentials
- Building a Next.js static export
- Creating an Azure DevOps YAML pipeline
- Adding manual approval before production deployment
-
Deploying automatically from the
mainbranch
Architecture Overview
Our deployment workflow will look like this:
Developer Push → Azure DevOps Pipeline
│
├── Build Next.js App
├── Export Static Files (out/)
├── Publish Artifact
├── Manual Approval
└── Deploy to Azure Static Web Apps
Step 1: Configure Next.js for Static Export
Azure Static Web Apps hosts static content efficiently.
For Next.js, configure static export in next.config.mjs.
Step 2: Create Azure Static Web App
In Azure Portal:
- Go to Azure Portal
- Create a new Static Web App
-
Choose:
- Hosting Plan: Free or Standard
- Deployment Source: Other
- Complete resource creation
After creation:
- Open the Static Web App
- Navigate to:
- Copy the deployment token
Step 3: Store Deployment Token in Azure DevOps
In Azure DevOps:
This generates a static out/ directory during build.
Create a variable group:
| Variable | Value |
|---|---|
| AZURE-SWA-DEPLOYMENT-TOKEN |
Step 4: Create the YAML Pipeline
Create a new file or download the files from the link below
Step 5: Create the Pipeline in Azure DevOps
- Go to:
Pipelines → New Pipeline
- Select repository
- Choose:
Existing Azure Pipelines YAML file
- Select:
azure-pipelines.yml
- Run the pipeline
How the Pipeline Works
Build Stage
The pipeline:
- installs Node.js
- installs dependencies
- runs Next.js build
-
validates the
out/directory - packages static files into a ZIP
- publishes artifact
Manual Approval Stage
Before deployment:
- reviewers receive approval notification
- deployment pauses
- approver validates build artifact
- Production deployment starts only after approval
Deployment Stage
The deployment stage:
- downloads artifact
- extracts static files
- installs Azure Static Web Apps CLI
- deploys the application to production
Final Thoughts
A single multi-stage YAML pipeline is usually the best approach for small-to-medium frontend applications because it keeps CI and CD tightly integrated while maintaining deployment control and traceability.
As your application grows, you can later extend the pipeline with:
- staging environments
- blue-green deployments
- automated testing
- reusable templates
- release orchestration