Azure Configuration & Deployment
Local Development Settings
Create or update local.settings.json in your API project:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"BlogFileShareName": "blog-content"
}
}
Configuration Properties:
AzureWebJobsStorage: Connection string for storage (development uses emulator)FUNCTIONS_WORKER_RUNTIME: Must be "dotnet-isolated" for .NET 10BlogFileShareName: Name of the file share containing blog posts
Azure File Share Setup
Step 1: Create Storage Account
- Go to Azure Portal
- Create new Storage Account
- Note the connection string for configuration
- Choose geographically close to your users for latency
Step 2: Create File Share
- In Storage Account → File shares
- Create new file share (name:
blog-contentor your preference) - Record the share name
Step 3: Create Blog Directory Structure
Using Azure Storage Explorer or Azure CLI:
# Create blog-posts directory in file share
# This is where all markdown files will be stored
Or programmatically via Azure Storage Explorer:
- Connect to storage account
- Navigate to file share
- Create folder
blog-posts - Create subfolder
blog-posts/imagesfor featured images
Step 4: Get Connection String
- Go to Storage Account → Access keys
- Copy connection string (under key1)
- Store securely (never commit to git)
Azure Static Web App Configuration
Environment Variables
Add these configuration variables to your Azure Static Web App:
# Using Azure CLI
az staticwebapp appsettings set \
--name your-app-name \
--setting-names \
BlogFileShareName=blog-content \
AzureWebJobsStorage="<your-connection-string>"
Or via Azure Portal:
- Go to Static Web App → Configuration
- Add Application settings: Name:
BlogFileShareNameValue:blog-contentName:AzureWebJobsStorageValue:<your-connection-string>
staticwebapp.config.json
Optional: Add routing configuration for blog URLs:
{
"routes": [
{
"route": "/blog/*",
"serve": "/index.html",
"statusCode": 200
},
{
"route": "/api/*",
"allowedRoles": ["authenticated", "anonymous"]
}
],
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["/api/*", "/*.{json,jpg,gif,png,webp,css,js,svg,eot,ttf,woff,woff2}"]
}
}
This ensures:
- Blog routes are handled by Blazor SPA (for client-side routing)
- API routes are passed through to Azure Functions
- Static assets are served correctly
Local Development Workflow
Prerequisites
- Install Azure Storage Emulator or use Azurite
- Start the emulator/Azurite
Running Locally
# Terminal 1: Start Azure Functions
cd src/YourProject.Api
func start
# Terminal 2: Start Blazor WASM with SWA CLI
swa start http://localhost:3000 --api-location api
Then navigate to: http://localhost:3000/blog
Testing Endpoints
# Test backend API directly
curl http://localhost:7071/api/blog/posts
curl http://localhost:7071/api/blog/posts/your-post-slug
# Test through SWA CLI
curl http://localhost:3000/api/blog/posts
File Share Content Format
Markdown File Structure
Store markdown files in Azure File Share at blog-posts/{slug}.md:
---
title: "Post Title"
slug: "post-slug"
author: "Your Name"
publishedDate: 2025-01-15T10:00:00Z
excerpt: "Brief summary for listings"
tags:
- tag1
- tag2
featuredImage: "/images/blog/featured.jpg"
readTimeMinutes: 5
---
# Post Title
Your markdown content here.
## Section 2
More content...
Required YAML Properties:
title: Blog post titleslug: URL-friendly identifier (must match filename without .md)author: Author namepublishedDate: ISO 8601 datetimeexcerpt: Summary for blog listings (50-150 chars)tags: Array of category tagsfeaturedImage: URL to featured imagereadTimeMinutes: Estimated reading time
Optional YAML Properties:
updatedDate: Last modification date
Image Management
- Upload images to
blog-posts/images/directory - Reference in markdown:
 - Use relative paths from web root
Deployment Checklist
Before deploying to production:
- ☐ Connection string configured in Static Web App settings
- ☐ Blog file share created and accessible
- ☐ Sample blog posts uploaded to file share
- ☐ Environment variable
BlogFileShareNameset correctly - ☐ API routes proxied in
staticwebapp.config.json - ☐ Blazor SPA routing configured for
/blog/* - ☐ CORS configured if needed (usually not for same-origin)
- ☐ SSL/TLS certificate valid (Azure SWA handles this)
- ☐ Functions runtime version matches .NET SDK
Monitoring & Troubleshooting
Azure Portal Monitoring
- Go to Static Web App → Settings → Functions
- Check function app logs
- Review Application Insights (if enabled)
Common Issues
Issue: 403 Forbidden accessing file share
- Verify connection string is correct
- Check storage account firewall settings
- Ensure managed identity has access (if using)
Issue: Blog posts not loading (404)
- Verify file share and blog-posts directory exist
- Check markdown file naming (use slug format)
- Verify connection string in configuration
Issue: Markdown not rendering
- Check Markdig package is installed in Client
- Verify markdown syntax is valid
- Look for console errors in browser dev tools
Issue: Featured images not loading
- Verify image URLs are correct
- Check image files exist in
blog-posts/images/ - Use CDN for better performance (future enhancement)
Local Debugging
Use Azure Storage Explorer to:
- Connect to your storage account
- Browse file share contents
- Verify markdown file structure
- Check frontmatter YAML syntax
- View file modification times
Security Considerations
Authentication & Authorization
- Blog endpoints are currently anonymous (AuthorizationLevel.Anonymous)
- For admin functions (create/update posts), add higher auth level
- Consider Azure AD for content management UI
Connection String Security
- Never commit connection string to git
- Use Azure Key Vault in production
- Use managed identities for Azure-hosted applications
- Store locally in user secrets (dev)
Content Security
- Sanitize user-generated content if accepting comments
- Validate image uploads if adding image management
- Implement rate limiting on API endpoints
- Use Content Security Policy headers
Performance Optimization
Caching Strategy
Frontend:
- Cache blog list for 5-10 minutes
- Cache individual posts for 1-2 hours
- Invalidate on new post upload
Backend:
- Add response caching headers
- Consider Redis cache layer for frequent posts
- Cache file share directory listing
CDN Optimization
- Use Azure CDN for static assets (images, CSS, JS)
- Set appropriate cache headers
- Enable gzip compression
- Optimize featured image sizes
Scaling Considerations
Current Architecture:
- Single file share (auto-scales)
- Serverless Azure Functions (auto-scales)
- Static hosting via SWA (auto-scales)
Future Enhancements:
- Add pagination for blog listings
- Implement search functionality
- Add caching layer
- Consider database for metadata (if thousands of posts)
Deployment Pipelines
GitHub Actions Example
name: Deploy Blog Feature
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and Deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/src/YourProject.Client"
api_location: "src/YourProject.Api"
output_location: "wwwroot"
Next Steps
- Create sample blog posts using
sample-content-troubleshooting.md - Deploy and validate in staging environment
- Monitor logs and performance metrics
- Plan content management workflow