This is a comprehensive .NET Aspire application that demonstrates a microservices architecture with Azure cloud resources and Docker containers.
The project includes the following components:
- Azure PostgreSQL Flexible Server - Primary database
- Azure Cache for Redis - Caching and session storage
- Feature Flag Service (.NET 8) - REST API for managing feature flags
- User Service (.NET 8) - REST API for user management
- Angular UI (Docker) - Frontend application using
featbit/featbit-ui:latest - Python Analytics Service (Docker) - FastAPI service for analytics and data processing
- .NET 10 SDK or later
- Docker Desktop (running)
- Azure subscription (for production deployment)
- Visual Studio 2022 or VS Code with C# Dev Kit
-
Clone the repository
git clone <repository-url> cd featbit-aspire
-
Restore dependencies
dotnet restore
-
Run the Aspire AppHost
dotnet run --project FeatBit.AppHost
-
Access the services:
- Aspire Dashboard: https://localhost:17106
- FeatBit Angular UI: http://localhost:8081
- FeatBit Web API: http://localhost:5000
- FeatBit Evaluation Server: http://localhost:5100
- FeatBit Data Analytics: http://localhost:8200
- Main API server for feature flag management
- Handles user authentication and authorization
- Manages feature flag configurations and targeting rules
- Provides administrative interfaces
- High-performance feature flag evaluation engine
- Handles real-time feature flag evaluations
- Optimized for low-latency responses
- Used by client SDKs for flag evaluations
- Complete web-based management interface
- Feature flag dashboard and configuration
- User management and analytics
- Access via browser at http://localhost:8081
- Analytics and reporting engine
- Data processing and insights
- Performance metrics and usage statistics
- Image:
featbitdocker/featbit-api-server:5.1.4 - Port: 5000
- Features: ASP.NET Core API with PostgreSQL and Redis integration
- Image:
featbitdocker/featbit-evaluation-server:5.1.4 - Port: 5100
- Features: High-performance evaluation engine
- Image:
featbitdocker/featbit-ui:5.1.4 - Port: 8081
- Features: Complete management interface
- Image:
featbitdocker/featbit-data-analytics-server:latest - Port: 8200
- Features: Python-based analytics and reporting
To add a new .NET service:
- Create the service project
- Add project reference in
FeatBit.AppHost.csproj - Register in
AppHost.cswithAddProject<>()
To add a new Docker service:
- Use
AddContainer()for existing images - Use
AddDockerfile()for custom builds
Services automatically receive connection strings for:
- PostgreSQL via
postgres.Resource.ConnectionStringExpression - Redis via
redis.Resource.ConnectionStringExpression
- Azure subscription with appropriate permissions
- Azure Developer CLI (azd) installed
- Existing PostgreSQL and Redis instances (connection strings configured in
appsettings.json)
-
Install Azure Developer CLI
# Windows (using winget) winget install microsoft.azd # Or download from https://aka.ms/azd-install
-
Login to Azure
azd auth login
-
Initialize the project
azd init --from-code
When prompted:
- Select
.NET (Aspire)as the detected service - Enter a unique environment name (e.g.,
featbit-aspire-env) - Confirm to continue
- Select
-
Deploy to Azure
azd up
During deployment, you'll be prompted to:
- Select your Azure subscription
- Choose a region (e.g.,
West US 2) - Enter PostgreSQL connection string
- Enter Redis connection string
The deployment will:
- Create a resource group (e.g.,
rg-featbit-aspire-env) - Create an Azure Container Apps Environment
- Create an Azure Container Registry
- Create Application Insights for monitoring
- Deploy all 4 container services with 3 replicas each for high availability
- Configure HTTPS endpoints automatically
-
Access your deployed application
After successful deployment, you'll see:
- FeatBit UI: https://featbit-ui.<environment>.azurecontainerapps.io/ - FeatBit API: https://featbit-api.<environment>.azurecontainerapps.io/ - Evaluation Server: https://featbit-evaluation-server.<environment>.azurecontainerapps.io/ - Aspire Dashboard: https://aspire-dashboard.ext.<environment>.azurecontainerapps.io
After making code changes, update your Azure deployment:
-
Quick update (code changes only)
azd deploy
This redeploys your services without reprovisioning infrastructure.
-
Full update (code + infrastructure changes)
azd up
Use this when you've modified
AppHost.csconfiguration. -
Update specific service
azd deploy <service-name> # Example: azd deploy featbit-api
View deployment status:
azd showView environment details:
azd env get-valuesMonitor logs:
azd monitorDelete all Azure resources:
azd down --force --purgeOr using Azure CLI:
az group delete --name rg-featbit-aspire-env --yes --no-waitThe deployment creates:
- Azure Container Apps Environment - Managed Kubernetes environment
- Azure Container Registry - Private container image storage
- Application Insights - Monitoring and telemetry
- Log Analytics Workspaces - Centralized logging
- 4 Container Apps (each with 3 replicas for high availability):
featbit-api- Web API Server (external HTTPS)featbit-evaluation-server- Evaluation Server (external HTTPS)featbit-ui- Angular UI (external HTTPS)featbit-da-server- Data Analytics (internal only)
The application automatically detects publish mode and:
- Uses explicit ports (5000, 5100, 8081) for local development
- Uses automatic port assignment (port 80) for Azure deployment
- Configures HTTPS endpoints for external services in Azure
- Sets up internal-only access for the Data Analytics service
- Configures environment variables with connection strings
- Enables Application Insights for monitoring
- Scales services with 3-10 replicas for high availability
To reduce costs in development:
- Modify replica counts in
AppHost.cs:containerApp.Template.Scale.MinReplicas = 1; containerApp.Template.Scale.MaxReplicas = 3;
- Delete resources when not in use:
azd down - Use Azure Cost Management to monitor spending
The Aspire Dashboard provides:
- Service health and status
- Logs from all services
- Metrics and telemetry
- Distributed tracing
- Resource usage
-
Docker not running
- Ensure Docker Desktop is started
- Check container status in Aspire Dashboard
-
Port conflicts
- Modify port assignments in
AppHost.cs - Use
WithHttpEndpoint(hostPort: <new-port>)
- Modify port assignments in
-
Azure connection issues
- Verify Azure CLI authentication:
az login - Check Azure subscription permissions
- Verify Azure CLI authentication:
Access logs through:
- Aspire Dashboard - Real-time logs for all services
- Docker Desktop - Container logs
- Azure Portal - Production logs (when deployed)
featbit-aspire/
βββ FeatBit.AppHost/ # Aspire orchestration
βββ FeatBit.ServiceDefaults/ # Shared service configuration
βββ FeatBit.FeatureFlagService/ # Feature flag REST API
βββ FeatBit.UserService/ # User management REST API
βββ python-app/ # Python analytics service
β βββ main.py
β βββ requirements.txt
β βββ Dockerfile
βββ README.md
- Fork the repository
- Create a feature branch
- Make changes and test locally
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.