Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions .azdevops/resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,14 @@ pool:

steps:
- task: AzureCLI@2
displayName: 'Deploy Bicep template'
inputs:
azureSubscription: $(azureSubscription)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az bicep build --file $(Build.SourcesDirectory)/Templates/resources.bicep

- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: '$(azureSubscription)'
subscriptionId: '$(subscriptionId)'
action: 'Create Or Update Resource Group'
resourceGroupName: '$(rgName)'
location: 'West Europe'
templateLocation: 'Linked artifact'
csmFile: '$(Build.SourcesDirectory)/Templates/resources.json'
csmParametersFile: '$(Build.SourcesDirectory)/Templates/resources.parameters.json'
deploymentMode: 'Incremental'
az deployment group create \
--resource-group $(rgName) \
--template-file $(Build.SourcesDirectory)/Templates/resources.bicep \
--parameters $(Build.SourcesDirectory)/Templates/resources.parameters.json \
--mode Incremental
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,42 @@ Components used

- Azure Functions
- Azure Storage (Blob, Table and Queues)
- Azure CDN
- Application Insights
- Custom Domain Support (optional)

## How to run

### Deploy with Azure CLI

```bash
# Clone the repository
git clone https://github.com/jhueppauff/ServerlessBlog.git
cd ServerlessBlog/Templates

# Deploy using Bicep
az deployment group create \
--resource-group <your-resource-group> \
--template-file resources.bicep \
--parameters resources.parameters.json
```

Or use the Deploy to Azure button (requires the resources.json to be present):

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fgithub.com%2Fjhueppauff%2FServerlessBlog%2Fblob%2Fmain%2FTemplates%2Fresources.json)

### Custom Domain Configuration

To add a custom domain to your blog:

1. Deploy the infrastructure using the Bicep template
2. Configure your DNS to point to the Azure Function Frontend:
- Add a CNAME record pointing to `<your-function-name>.azurewebsites.net`
3. Update the `customDomainName` parameter in `resources.parameters.json` with your domain (e.g., `blog.yourdomain.com`)
4. Redeploy the template to bind the custom domain
5. Azure will automatically provision an SSL certificate for HTTPS

Note: The custom domain parameter is optional. If left empty, the blog will be accessible via the default Azure Function URL.

## How to customize

Currently the Blog has some static assets sitting in the Frontend and Engine Function. If you like to change HTML, CSS you need to update the html files in the statics Folder.
160 changes: 160 additions & 0 deletions Templates/MIGRATION_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Azure CDN Replacement Migration Notes

## Overview
This migration removes Azure CDN from the ServerlessBlog infrastructure and adds direct custom domain support to the Azure Function Frontend.

## Changes Made

### 1. Removed Components
- **Azure CDN Profile** (`microsoft.cdn/profiles@2019-04-15`)
- **Azure CDN Endpoint** (`microsoft.cdn/profiles/endpoints@2019-04-15`)
- Parameters: `profileProperties` and `endpointProperties`
- Variables: `cdnProfileName_var` and `cdnEndpointName`

### 2. Added Components
- **Custom Domain Support**: Optional custom domain binding for Function Frontend
- New parameter: `customDomainName` (string, optional)
- New resource: `functionFrontendCustomDomain` (conditional deployment based on customDomainName)
- Automatic SSL/TLS certificate provisioning via Azure
- SNI-based SSL enabled

### 3. Infrastructure Improvements (Azure Verified Modules Pattern)
- Added `@description` decorators to all parameters for better documentation
- Organized bicep file with section comments:
- Parameters
- Variables
- Static Web App (Editor)
- Service Bus
- RBAC Role Definitions
- RBAC Role Assignments
- Storage Accounts
- App Service Plan
- Function Apps
- Monitoring
- Cosmos DB

- Updated API versions to latest stable:
- Static Web Apps: `2023-01-01`
- Service Bus: `2022-10-01-preview`
- Storage Accounts: `2023-01-01`
- App Service Plan/Functions: `2023-01-01`
- Log Analytics: `2022-10-01`
- Cosmos DB: `2023-11-15`

- Security enhancements:
- Added `httpsOnly: true` to Function Frontend
- Updated authentication to `authsettingsV2` for Function Engine
- Added `minimumTlsVersion: '1.2'` to Service Bus
- Explicitly set `allowBlobPublicAccess: false` on storage accounts

- Code quality improvements:
- Removed `_var` suffix from variable names
- Added inline comments for RBAC role IDs
- Improved resource organization and readability

## Migration Path

### For Existing Deployments
1. **DNS Configuration** (if using custom domain):
- Create CNAME record pointing to `<function-name>.azurewebsites.net`
- Update parameters file with your custom domain

2. **Update Parameters**:
```json
{
"customDomainName": {
"value": "blog.yourdomain.com" // or "" if not using custom domain
}
}
```

3. **Deploy Updated Template**:
```bash
az deployment group create \
--resource-group <your-rg> \
--template-file resources.bicep \
--parameters resources.parameters.json
```

4. **Clean Up Old CDN Resources** (manual step):
- The CDN resources won't be automatically deleted
- Delete them manually via Azure Portal or CLI to avoid ongoing charges

### For New Deployments
- Simply deploy the updated template
- Optionally configure custom domain by setting the `customDomainName` parameter

## Benefits

1. **Simplified Architecture**:
- Fewer moving parts
- Reduced complexity
- Lower management overhead

2. **Cost Optimization**:
- Eliminates CDN costs
- Azure Functions already provide good performance with global distribution

3. **Better Security**:
- Direct HTTPS enforcement
- Managed SSL certificates
- Modern authentication (authsettingsV2)

4. **Improved Maintainability**:
- Better documented code
- Latest API versions
- Follows Azure best practices

## Custom Domain Configuration

### Steps to Configure Custom Domain:

1. **Deploy Infrastructure First**:
```bash
az deployment group create \
--resource-group <your-rg> \
--template-file resources.bicep \
--parameters resources.parameters.json
```

2. **Configure DNS**:
- Add CNAME record in your DNS provider
- Point to: `<your-function-name>.azurewebsites.net`
- Wait for DNS propagation (usually 5-15 minutes)

3. **Update Parameters and Redeploy**:
```json
{
"customDomainName": {
"value": "blog.yourdomain.com"
}
}
```

4. **Verify**:
- Azure will automatically provision and bind an SSL certificate
- Access your blog at `https://blog.yourdomain.com`

## Rollback Plan

If you need to rollback to the previous CDN-based infrastructure:

1. Revert to the previous version of the bicep template
2. Redeploy with the old parameters file
3. Update DNS to point back to the CDN endpoint

## Testing

All changes have been validated:
- βœ… Bicep compilation successful
- βœ… No CDN references remaining
- βœ… Custom domain resource correctly configured
- βœ… All API versions updated to stable releases
- βœ… Parameter validation successful

## Support

For questions or issues related to this migration, please:
1. Check the README.md for custom domain configuration
2. Review this migration document
3. Open an issue on GitHub if problems persist
Loading