Environment Variables
Configure AuthScape using environment variables.
Environment variables provide a secure way to configure AuthScape, especially in containerized and cloud environments.
Quick Setup Script
We provide an interactive script to help configure environment variables. Important: Download and review the script before running.
Windows (PowerShell)
Step 1: Download the script
Invoke-WebRequest -Uri "https://docs.authscape.com/scripts/setup-env.ps1" -OutFile "setup-env.ps1"
Step 2: Review and edit (optional)
Open setup-env.ps1 in your text editor to review what it does. You can also pre-fill values by editing the script directly instead of entering them interactively.
# Open in Notepadnotepad setup-env.ps1# Or open in VS Codecode setup-env.ps1
Step 3: Run the script
.\setup-env.ps1
The script will interactively prompt you for:
- Database connection details
- API and client URLs
- Stripe keys (optional)
- SendGrid email configuration (optional)
- Azure Blob Storage (optional)
- Lucene search / Marketplace (optional)
- AI services (optional)
Press ENTER to skip any field you don't want to configure.
Linux/Mac (Bash)
Step 1: Download the script
curl -O https://docs.authscape.com/scripts/setup-env.sh
Step 2: Review and edit (optional)
Open setup-env.sh in your text editor to review what it does. You can also pre-fill values by editing the script.
# Open in nanonano setup-env.sh# Or open in vimvim setup-env.sh# Or open in VS Codecode setup-env.sh
Step 3: Make executable and run
chmod +x setup-env.sh./setup-env.sh
Step 4: Apply changes
source ~/.bashrc # or ~/.zshrc depending on your shell
Cleanup Script
To remove all AuthScape environment variables:
Windows (PowerShell)
# Download cleanup scriptInvoke-WebRequest -Uri "https://docs.authscape.com/scripts/cleanup-env.ps1" -OutFile "cleanup-env.ps1"# Review it (optional)notepad cleanup-env.ps1# Run it.\cleanup-env.ps1
Linux/Mac (Bash)
# Download cleanup scriptcurl -O https://docs.authscape.com/scripts/cleanup-env.sh# Review it (optional)cat cleanup-env.sh# Make executable and runchmod +x cleanup-env.sh./cleanup-env.sh
Manual Setup
If you prefer to set variables manually:
Setting Environment Variables
Windows
# Temporary (current session)$env:ConnectionStrings__DefaultConnection = "Server=localhost;..."# Permanent (user level)[Environment]::SetEnvironmentVariable("AppSettings__Stripe__SecretKey", "sk_xxx", "User")
Linux/Mac
# Temporaryexport ConnectionStrings__DefaultConnection="Server=localhost;..."# Permanent (add to ~/.bashrc or ~/.zshrc)echo 'export AppSettings__Stripe__SecretKey="sk_xxx"' >> ~/.bashrc
Naming Convention
Environment variables use double underscores (__) to represent hierarchy:
| appsettings.json | Environment Variable |
|---|---|
ConnectionStrings.DefaultConnection | ConnectionStrings__DefaultConnection |
AppSettings.Stripe.SecretKey | AppSettings__Stripe__SecretKey |
Logging.LogLevel.Default | Logging__LogLevel__Default |
Docker Configuration
ENV ConnectionStrings__DefaultConnection="Server=db;Database=AuthScape;..."ENV AppSettings__BaseUri="https://api.example.com"
Or with docker-compose:
services:api:environment:- ConnectionStrings__DefaultConnection=Server=db;Database=AuthScape;...- AppSettings__BaseUri=https://api.example.com
Azure App Service
Set in Configuration > Application settings:
| Name | Value |
|---|---|
ConnectionStrings__DefaultConnection | Server=... |
AppSettings__Stripe__SecretKey | sk_live_xxx |
Loading Priority
Environment variables override appsettings.json:
var builder = WebApplication.CreateBuilder(args);// Order of precedence (highest to lowest):// 1. Command-line arguments// 2. Environment variables// 3. User secrets (Development only)// 4. appsettings.[Environment].json// 5. appsettings.json