This project demonstrates how to use .NET Aspire to build and deploy a static website (built with Vite/TypeScript) to Azure Storage with static website hosting enabled.
- .NET 9.0 SDK or later
- Node.js (for building the static site)
- Azure CLI (for authentication)
- An Azure subscription
- Aspire CLI daily
To run the Aspire orchestration locally:
aspire runThis will start the Aspire dashboard where you can monitor your application.
Make sure you're logged into Azure CLI:
az loginSet your subscription (if you have multiple):
az account set --subscription "your-subscription-id"Generate the Azure infrastructure files:
aspire publishThis command will:
- Generate Bicep templates for Azure resources
- Create configuration files for deployment
- Output files to the
generated/directory
Deploy the application and infrastructure to Azure:
aspire deployThis command will:
- Build the static site: Run
npm installandnpm run buildin thestatic-sitedirectory - Deploy Azure infrastructure: Create Azure Storage Account with static website hosting enabled
- Configure static website: Enable static website hosting with
index.htmlas the index document - Upload files: Upload the built static files to the
$webcontainer in Azure Storage
The deployment process includes several automated steps:
-
Static Site Build
- Runs
npm installto install dependencies - Runs
npm run buildto create production build indist/folder
- Runs
-
Azure Storage Configuration
- Creates Azure Storage Account with public blob access enabled
- Configures static website hosting with:
- Index document:
index.html - Error document:
index.html(for SPA routing)
- Index document:
-
File Upload
- Uploads all files from
static-site/dist/to the$webcontainer - Overwrites existing files to ensure latest version is deployed
- Uploads all files from
The deployment creates:
- Storage Account: For hosting static files
- Static Website Configuration: Enables static website hosting on the storage account
- $web Container: Special container that serves as the website root
- Azure Front Door: For routing requests
