Skip to main content

Environments

Satélite API supports multiple deployment environments with distinct configurations for production operations and development testing.

Available Environments

Satélite API maintains two primary deployment environments:

Production

Environment: ProductionURL: https://sateliteappapi.azurewebsites.netPurpose: Live production operations with real business dataCharacteristics:
  • High availability configuration
  • Auto-scaling enabled
  • Production database connections
  • Enhanced security and monitoring
  • Minimal logging for performance

Testing

Environment: QualityURL: https://sateliteappapi-test.azurewebsites.netPurpose: Development, testing, and QA validationCharacteristics:
  • Test database connections
  • Detailed logging enabled
  • Rapid deployment cycles
  • Isolated from production data
  • Lower resource allocation

Environment Configuration

The active environment is controlled by the ASPNETCORE_ENVIRONMENT variable, which determines which configuration files are loaded and how the application behaves.

Setting the Environment

# Set via Azure CLI
az webapp config appsettings set \
  --name sateliteappapi \
  --resource-group satelite-rg \
  --settings ASPNETCORE_ENVIRONMENT="Production"

Environment Values

Value: ProductionUsed for:
  • Production Azure Web App (sateliteappapi.azurewebsites.net)
  • Live customer-facing operations
  • Real business data processing
Configuration file: appsettings.Production.json
launchSettings.json:12-21
"SateliteApi": {
  "commandName": "Project",
  "dotnetRunMessages": true,
  "launchBrowser": true,
  "launchUrl": "graphql",
  "applicationUrl": "https://localhost:7251",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Production"
  }
}
Value: QualityUsed for:
  • Testing Azure Web App (sateliteappapi-test.azurewebsites.net)
  • QA and UAT testing
  • Development validation
Configuration file: appsettings.Quality.json
launchSettings.json:22-29
"IIS Express": {
  "commandName": "IISExpress",
  "launchBrowser": true,
  "launchUrl": "swagger",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Quality"
  }
}
Value: DevelopmentUsed for:
  • Local development on developer machines
  • Debugging and development features enabled
  • Detailed error pages and diagnostics
Configuration file: appsettings.Development.json
Development environment is not deployed to Azure. It’s only for local development.

Environment-Specific Settings

Configuration File Structure

Configuration is loaded in this order:
1

Base Configuration

appsettings.json - Shared settings across all environments
2

Environment Override

appsettings.{Environment}.json - Environment-specific overrides
3

Azure App Settings

Azure Portal App Settings - Highest priority, overrides all files
4

Environment Variables

System environment variables - Can override any setting

Example Configuration Structure

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Jwt": {
    "Issuer": "SateliteApi",
    "Audience": "SateliteApi"
  }
}

Database Connections by Environment

Each environment connects to separate database instances to maintain data isolation:
Connection Strings: Point to production SQL Server instances
  • SateliteConnection → Production Satélite DB
  • CajachicaConnection → Production Cajachica DB
  • AnticiposConnection → Production Anticipos DB
  • NexusConnection → Production Nexus DB
  • And all other production databases…
Retry Configuration: Enabled for BitacoraCumplimientoDBContext and NexusDBContext
Program.cs:274-280
builder.Services.AddPooledDbContextFactory<BitacoraCumplimientoDBContext>(
    options => options.UseSqlServer(builder.Configuration.GetConnectionString("SateliteConnection"),
        sqlOptions => sqlOptions.EnableRetryOnFailure(
            maxRetryCount: 5,                      
            maxRetryDelay: TimeSpan.FromSeconds(30),
            errorNumbersToAdd: null                 
        )));

Switching Between Environments

For Azure Deployment

1

Update App Setting

Change ASPNETCORE_ENVIRONMENT in Azure Portal:
  1. Navigate to Web App > Configuration
  2. Under Application settings, find ASPNETCORE_ENVIRONMENT
  3. Change value to desired environment (Production or Quality)
  4. Click Save
2

Update Connection Strings

Verify connection strings point to correct databases:
  1. Go to Configuration > Connection strings
  2. Update each connection string to target correct database
  3. Click Save
3

Restart Application

Restart the Web App to apply changes:
az webapp restart \
  --name sateliteappapi \
  --resource-group satelite-rg

For Local Development

  1. Open Properties/launchSettings.json
  2. Locate the profile you want to use
  3. Change ASPNETCORE_ENVIRONMENT value
  4. Save and restart debugger
"SateliteApi": {
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Production"  // Change here
  }
}

Environment-Specific Behaviors

Logging Levels

Production

Minimal Logging
  • Errors and Critical only
  • Reduced console output
  • Performance optimized
  • Log to Application Insights

Testing

Detailed Logging
  • Information and Debug levels
  • Verbose console output
  • Request/response logging
  • Easier troubleshooting

GraphQL Features

Both environments share the same GraphQL configuration:
  • 10-minute execution timeout
  • Automatic persisted queries disabled in production
  • Introspection enabled in testing
  • GraphQL playground available in testing only

Scheduled Jobs

Scheduled jobs run in both environments but with different schedules:
// Anticipo/Reembolso: Daily at 9:00 AM
"0 0 9 * * ?"

// Bitacora Caducidad: Daily at 8:00 AM
"0 0 8 * * ?"

// Gestor: Daily at 6:00 AM
"0 0 6 * * ?"

Security Considerations

Never share credentials between environmentsEach environment must have:
  • Separate database credentials
  • Different JWT signing keys
  • Unique API keys for external services
  • Isolated Azure resources
  • Enable Azure AD authentication
  • Use Azure Key Vault for all secrets
  • Restrict CORS to specific origins
  • Enable Application Insights security monitoring
  • Configure Web Application Firewall (WAF)
  • Regular security audits and penetration testing
  • Use separate service principals
  • Limit access to test data only
  • Allow broader CORS for development
  • Use non-production API credentials
  • Regular cleanup of test data

Best Practices

1

Always Test First

Deploy and test all changes in the Quality environment before promoting to Production
2

Use Configuration Files

Store environment-specific settings in configuration files, not in code
3

Monitor Both Environments

Set up Application Insights for both Production and Quality to catch issues early
4

Automate Deployments

Use CI/CD pipelines to ensure consistent deployments across environments
5

Maintain Parity

Keep Testing environment as close to Production as possible in configuration and infrastructure

Environment Health Checks

Verify environment is correctly configured:
curl https://sateliteappapi.azurewebsites.net/graphql

# Should return GraphQL playground or schema

Troubleshooting

Symptom: Application connects to incorrect databaseSolution:
  1. Verify ASPNETCORE_ENVIRONMENT is set correctly
  2. Check connection strings in Azure Portal
  3. Ensure configuration file naming matches environment exactly
  4. Restart the application after changes
Symptom: Changes to environment variables don’t applySolution:
  1. Verify the variable is set in correct location (Azure App Settings)
  2. Click Save in Azure Portal after changes
  3. Restart the Web App
  4. Check logs to confirm environment is loaded correctly
Symptom: Unexpected configuration valuesSolution: Remember configuration priority order:
  1. Environment variables (highest)
  2. Azure App Settings
  3. appsettings..json
  4. appsettings.json (lowest)
Higher priority sources override lower ones.

Next Steps

Azure Setup

Learn how to deploy to Azure Web Services

Configuration

Configure connection strings and application settings

Build docs developers (and LLMs) love