This EventGrid Viewer Blazor application can be deployed using the Azure Developer CLI (azd) for a streamlined development and deployment experience.
- Azure Developer CLI
- .NET 9.0 SDK
- Azure CLI (optional, for additional Azure operations)
-
Clone and navigate to the repository:
git clone https://github.com/Azure-Samples/eventgrid-viewer-blazor.git cd eventgrid-viewer-blazor -
Initialize the Azure Developer CLI environment:
azd auth login azd init
-
Deploy the application:
azd up
This single command will:
- Provision Azure resources (App Service, Application Insights, Log Analytics)
- Build and deploy the .NET application
- Configure all necessary settings
-
Get the webhook URL:
azd env get-values
Look for
EVENTGRID_WEBHOOK_URLin the output.
You can customize the deployment by setting environment variables:
# Set the Azure region
azd env set AZURE_LOCATION eastus2
# Set the App Service SKU
azd env set AZURE_APP_SERVICE_SKU B1
# Enable authentication (requires additional setup)
azd env set AZURE_ENABLE_AUTH true
azd env set AZURE_KEYVAULT_NAME your-keyvault-name
azd env set AZURE_AD_DOMAIN your-domain.onmicrosoft.com| Variable | Default | Description |
|---|---|---|
AZURE_LOCATION |
eastus2 |
Azure region for deployment |
AZURE_APP_SERVICE_SKU |
F1 |
App Service plan SKU |
AZURE_ENABLE_AUTH |
false |
Enable Azure AD authentication |
AZURE_KEYVAULT_NAME |
Key Vault name for auth secrets | |
AZURE_AD_DOMAIN |
Azure AD domain for authentication | |
AZURE_REPO_URL |
Current repo | GitHub repository URL |
AZURE_REPO_BRANCH |
main |
GitHub branch to deploy |
To enable Azure AD authentication:
- Create an Azure AD app registration
- Create a Key Vault and store the client ID:
az keyvault secret set --vault-name <your-keyvault> --name "sct-egvb-azad-client-id" --value "<your-client-id>"
- Set the authentication environment variables:
azd env set AZURE_ENABLE_AUTH true azd env set AZURE_KEYVAULT_NAME your-keyvault-name azd env set AZURE_AD_DOMAIN your-domain.onmicrosoft.com
- Redeploy:
azd deploy
# Run the application locally
dotnet run --project src/Blazor.EventGridViewer.ServerApp
# Or use the VS Code task
# Press Ctrl+Shift+P, then "Tasks: Run Task" > "run"The project includes a GitHub Actions workflow (.github/workflows/azure-dev.yml) that automatically deploys on pushes to main. To set this up:
- Fork the repository
- Set up GitHub variables for your Azure environment:
AZURE_CLIENT_IDAZURE_TENANT_IDAZURE_SUBSCRIPTION_IDAZURE_ENV_NAMEAZURE_LOCATION
# Deploy infrastructure and application
azd up
# Deploy application only (faster for code changes)
azd deploy
# View environment variables and resource URLs
azd env get-values
# View deployment logs
azd monitor
# Clean up all resources
azd downResources are automatically named using the pattern:
- App Service:
app-{env-name}-{random-suffix} - App Service Plan:
plan-{env-name}-{random-suffix} - Application Insights:
ai-{app-name}-{env-name} - Log Analytics:
law-{app-name}-{env-name}
The infrastructure is defined in Bicep templates under the infra/ directory:
main.bicep- Main template orchestrating all resourcesmodules/monitoring.bicep- Application Insights and Log Analyticsmodules/appservice.bicep- App Service and App Service Plan
-
Deployment fails with SKU not available: Try a different Azure region or SKU:
azd env set AZURE_LOCATION westus2 azd env set AZURE_APP_SERVICE_SKU B1
-
Resource names already exist: Change the environment name:
azd env set AZURE_ENV_NAME myapp-dev-v2 -
Authentication not working: Ensure the Key Vault exists and contains the client ID secret
- View detailed logs:
azd deploy --debug - Check Azure resources: Visit the Azure Portal
- Azure Developer CLI docs: aka.ms/azure-dev
After deployment, you can:
- Configure Event Grid subscriptions to point to:
{your-app-url}/api/eventgrid - View real-time events in the web application
- Monitor application performance in Application Insights
- Scale the App Service plan as needed
For more advanced scenarios, see the original README.md.