Host a .NET Blazor WebAssembly App on Amazon S3 and Amazon CloudFront
.NET on AWS Blog
This article demonstrates how to host a .NET Blazor WebAssembly application on AWS using Amazon S3 and CloudFront with infrastructure-as-code via Terraform.
- Blazor WASM compiles to static files (HTML, CSS, JavaScript, WASM binaries) suitable for S3 storage and CloudFront distribution
- Use Origin Access Control (OAC) to securely restrict S3 bucket access to a specific CloudFront distribution via SigV4 signing
- Implement two cache policies: one-year immutable caching for content-hashed _framework/* files and zero-TTL for index.html to ensure fresh deployments
- Configure CloudFront custom error responses to rewrite 403/404 errors to index.html for proper SPA client-side routing and deep link support
- Deploy script handles correct MIME types and Content-Encoding headers for pre-compressed Brotli files, then invalidates CloudFront cache
- Optional custom domain support via ACM certificate and Route 53 DNS records
This serverless hosting approach eliminates compute costs, provides global low-latency access through 400+ edge locations, and requires no server management or patching.
The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.
Related articles
The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.