Skip to content

featbit/featbit-aspire

Repository files navigation

FeatBit Aspire - Deploy FeatBit to Azure with .NET Aspire

Deploy FeatBit - an open-source feature flag management platform - to Azure using .NET Aspire.

🏗️ Architecture

Services:

  • FeatBit Web API - Main API server for feature flag management
  • FeatBit Evaluation Server - High-performance evaluation engine
  • FeatBit UI - Angular-based web interface
  • FeatBit Data Analytics - Analytics and reporting service

Infrastructure:

  • Database - PostgreSQL or MongoDB (configurable)
  • Cache - Redis
  • Monitoring - Azure Application Insights (when deployed to Azure)

⚙️ Prerequisites

  • Azure subscription
  • Azure Developer CLI (azd) - Install guide
  • PostgreSQL or MongoDB database - Create a database instance and run FeatBit database initialization scripts:
  • Redis instance - Set up a Redis cache instance (local or cloud)

🚀 Deploy to Azure

1. Clone Repository

git clone https://github.com/featbit/featbit-aspire.git
cd featbit-aspire

2. Configure Database and Redis

Edit FeatBit.AppHost/appsettings.json with your database and Redis connection strings:

For PostgreSQL:

{
  "DbProvider": "Postgres",
  "ConnectionStrings": {
    "Postgres": "Host=yourhost;Database=featbit;Username=user;Password=pass;Port=5432",
    "Redis": "yourhost:6379,password=yourpassword,ssl=True"
  }
}

For MongoDB:

{
  "DbProvider": "MongoDb",
  "ConnectionStrings": {
    "MongoDb": "mongodb://yourhost:27017/featbit",
    "Redis": "yourhost:6379,password=yourpassword,ssl=True"
  },
  "MongoDb": {
    "Database": "featbit",
    "Host": "mongodb"
  }
}

3. Secure Your Credentials (Recommended)

⚠️ Security Best Practice: The connection strings in appsettings.json contain sensitive credentials. For production deployments, consider these options:

Option A: Deploy with appsettings.json (Quick Start)

  • Use the credentials in appsettings.json as-is
  • ⚠️ Ensure the file is in .gitignore to avoid committing secrets
  • Suitable for testing and development

Option B: Use Environment Variables (Recommended)

  • Remove credentials from appsettings.json
  • Set them as environment variables before deployment
  • More secure, credentials not stored in code
# Windows PowerShell
$env:ConnectionStrings__MongoDb="mongodb://your-connection-string"
$env:ConnectionStrings__Redis="your-redis-connection-string"

# Linux/Mac
export ConnectionStrings__MongoDb="mongodb://your-connection-string"
export ConnectionStrings__Redis="your-redis-connection-string"

Option C: Use Azure Key Vault (Production)

4. Login to Azure

azd auth login

A browser window will open for Azure authentication. Sign in with your Azure account.

5. Initialize and Deploy

azd up

This command will initialize and deploy in one step. During the process, you'll be prompted for several inputs:

Prompt 1: Environment Name

? Enter a new environment name: [? for help]
  • Enter a unique name (e.g., featbit-prod, featbit-dev)
  • This will be used in resource naming (e.g., rg-featbit-prod)
  • Use lowercase letters, numbers, and hyphens only

Prompt 2: Azure Subscription (if you have multiple subscriptions)

? Select an Azure Subscription to use:
  1. Subscription 1 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
> 2. Subscription 2 (yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy)
  3. Subscription 3 (zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz)
  • Use arrow keys to select your subscription
  • Press Enter to confirm

Prompt 3: Azure Region

? Select an Azure location to use:
  1. (US) East US (eastus)
> 2. (US) West US 2 (westus2)
  3. (Europe) West Europe (westeurope)
  4. (Asia Pacific) Southeast Asia (southeastasia)
  ...
  • Select the region closest to your users
  • Common choices: eastus, westus2, westeurope, southeastasia
  • Press Enter to confirm

Deployment Progress:

After providing these inputs, the deployment begins:

Initializing project...

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time

  (✓) Done: Resource group: rg-featbit-prod
  (✓) Done: Container Apps Environment: featbit-env
  (✓) Done: Log Analytics workspace
  (✓) Done: Application Insights

Deploying services (azd deploy)

  (✓) Done: Deploying service featbit-ui
  - Endpoint: https://featbit-ui.xxx.eastus.azurecontainerapps.io
  
  (✓) Done: Deploying service featbit-api
  - Endpoint: https://featbit-api.xxx.eastus.azurecontainerapps.io
  
  (✓) Done: Deploying service featbit-evaluation-server
  - Endpoint: https://featbit-evaluation-server.xxx.eastus.azurecontainerapps.io

SUCCESS: Your application was deployed to Azure in 12 minutes.

⏱️ Expected Time: 10-15 minutes total

6. Access Your Deployment

After deployment completes, note the endpoints displayed:

  • FeatBit UI: https://featbit-ui.<random>.azurecontainerapps.io
  • FeatBit Web API: https://featbit-api.<random>.azurecontainerapps.io
  • FeatBit Evaluation Server: https://featbit-evaluation-server.<random>.azurecontainerapps.io

Default Login:

7. Enable WebSocket Support for Evaluation Server

The FeatBit Evaluation Server requires WebSocket support. Enable sticky sessions (session affinity) using Azure CLI:

az containerapp ingress sticky-sessions set \
  --name featbit-evaluation-server \
  --resource-group rg-featbit-trial \
  --affinity sticky

Note: Replace rg-featbit-trial with your resource group name if different. This configuration persists across azd deploy runs but may need to be reapplied after azd up.

🔄 Update Deployment

When you need to update your deployed application (e.g., upgrading to a new FeatBit version), use:

azd deploy

This command is sufficient for most updates, including:

  • Upgrading Docker image versions in AppHost.cs (e.g., featbit/featbit-api-server:5.1.45.2.0)
  • Changing environment variables in appsettings.json
  • Updating configuration settings

Deployment Process

When you run azd deploy, it will detect changes and prompt for confirmation:

$ azd deploy

? The following services will be updated. Continue? (Y/n)
  - featbit-api
  - featbit-ui

Press Y to confirm and proceed with deployment.

Deployment output:

Deploying services (azd deploy)

  (✓) Done: Deploying service featbit-api
  - Endpoint: https://featbit-api.xxx.eastus.azurecontainerapps.io
  
  (✓) Done: Deploying service featbit-ui
  - Endpoint: https://featbit-ui.xxx.eastus.azurecontainerapps.io

SUCCESS: Your application was deployed to Azure in 3 minutes 45 seconds.

What gets updated:

  • Modified container images are pulled and deployed
  • Updated services are redeployed with zero downtime
  • New environment variables (if changed in appsettings.json)
  • Health checks verify services are running correctly

If no changes are detected:

$ azd deploy

  (✓) Done: Service featbit-api is up to date
  (✓) Done: Service featbit-ui is up to date

SUCCESS: All services are up to date.

When to Use azd up Instead

Use azd up only when you've made infrastructure-level changes:

azd up

Examples requiring azd up:

  • Adding or removing services in AppHost.cs
  • Changing scaling rules (min/max replicas, CPU/memory limits)
  • Modifying network configuration (ports, ingress settings)
  • Updating Container Apps Environment settings

Note: For most day-to-day updates (like upgrading FeatBit versions), azd deploy is faster and sufficient.

Quick Reference:

  • Upgrading FeatBit versions (changing image tags) → Use azd deploy (⏱️ ~3-5 min)
  • Adding/removing services or changing infrastructure → Use azd up (⏱️ ~10-15 min)

📊 Monitor Deployment

# View all resources and endpoints
azd show

# View logs
azd logs

# Open Application Insights
azd monitor

🧹 Clean Up

Remove all Azure resources:

azd down

You'll be prompted to confirm:

? Total resources to delete: 6, are you sure you want to continue? (y/N)

Type y and press Enter to delete all resources.

📋 Azure Resources Created

The deployment creates:

  • Azure Container Apps Environment - Managed hosting environment

  • Application Insights - Monitoring and telemetry

  • Log Analytics Workspace - Centralized logging

  • 4 Container Apps (each with 3-10 replicas):

    • 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)

    ⚙️ Host configuration notes

    • Replica range: Container Apps are configured with a minimum of 3 and maximum of 10 replicas (see host files in FeatBit.AppHost).
    • Resource allocation: API, Evaluation Server, and Data Analytics services are configured with 0.75 CPU and 1.5Gi memory.
    • Default image tag: Container images in the host are set to latest by default — change the image tags in FeatBit.AppHost to pin versions before production deploys.
    • Service ports: API 5000, Evaluation Server 5100, UI (development 8081, publish/container 80), Data Analytics (development 8200 → container 80).
    • DbProvider default: When DbProvider is not set the host defaults to Postgres.
    • Application Insights: Application Insights is only added when running in publish/Azure mode (publish-time monitoring).
    • Health checks: API and Evaluation Server use /health/liveness endpoint for health monitoring.
    • External endpoints: ⚠️ Important: WithExternalHttpEndpoints() must be called before PublishAsAzureContainerApp() for proper Azure Container Apps ingress configuration. This ordering is critical for external access to work correctly.

🔧 Troubleshooting

Deployment fails:

# Run with debug output
azd deploy --debug

# Check authentication
azd auth login
az account show

Update connection strings after deployment:

az containerapp update \
  --name featbit-api \
  --resource-group rg-<your-env-name> \
  --set-env-vars \
    "Postgres__ConnectionString=<your-connection>" \
    "Redis__ConnectionString=<your-redis-connection>"

View logs:

# All services
azd logs

# Specific service
azd logs --service featbit-api

� Helpful Tips

Using MicrosoftDocs MCP Server for Deployment Troubleshooting and Assistance

The MicrosoftDocs MCP Server can significantly enhance your deployment experience by providing real-time access to official Azure documentation and best practices. This MCP Server was heavily relied upon during the creation and testing of this project, offering:

  • Accurate Azure guidance - Access to up-to-date Azure documentation and examples
  • Deployment assistance - Step-by-step help with Azure Container Apps, azd commands, and configurations
  • Troubleshooting support - Quick answers to common Azure deployment issues

If you're using an AI assistant that supports MCP (Model Context Protocol), consider configuring the MicrosoftDocs MCP Server for a smoother deployment experience.

�📚 Resources

📄 License

This project follows the same license as FeatBit. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages