Music Albums REST API written in C# / .NET Core, with Dapper and PostgreSQL
A live version of this API is deployed on Azure Container Apps:
Note: This is a demo instance and may be scaled down to zero when not in use. The first request might take a few seconds while the container starts.
- API Testing Guide - HTTP requests for testing all endpoints
- Infrastructure - Bicep modules and Azure deployment
- Identity API - JWT token generator (helper tool)
Secrets are stored in User Secrets (outside the repo, never committed).
1. Set your secrets (User Secrets for main API):
cd src/MusicAlbums.Api
dotnet user-secrets set "Database:ConnectionString" "Server=localhost;Port=5433;Database=albums;User ID=dev;Password=changeme;"
dotnet user-secrets set "Jwt:Key" "your-secret-key-min-32-chars"
dotnet user-secrets set "ApiKey" "your-api-key"2. Set Identity API secret (User Secrets):
cd tools/Identity.Api
dotnet user-secrets set "Jwt:Key" "your-secret-key-min-32-chars"This key must match the Jwt:Key used by src/MusicAlbums.Api for token validation to work.
3. Configure database credentials (Docker - Optional):
Docker Compose uses these defaults: dev / changeme / albums on port 5433
If you want different values, copy the example and customize:
cp .env.example .env
# Edit .env with your valuesNote: Don't edit docker-compose.yml directly - use .env to override defaults.
Keep ports in sync: If you change POSTGRES_PORT in .env, update your connection string to match:
cd src/MusicAlbums.Api
dotnet user-secrets set "Database:ConnectionString" "Server=localhost;Port=YOUR_NEW_PORT;Database=albums;User ID=dev;Password=changeme;"docker-compose up -d # Start database
cd src/MusicAlbums.Api
dotnet run# List all secrets
cd src/MusicAlbums.Api
dotnet user-secrets list
# Open secrets file directly (Windows)
code "$env:APPDATA\Microsoft\UserSecrets\<UserSecretsId>\secrets.json"
# Open secrets file directly (Linux/macOS)
code ~/.microsoft/usersecrets/<UserSecretsId>/secrets.jsonFind <UserSecretsId> in MusicAlbums.Api.csproj or Identity.Api.csproj.
Create two Azure DevOps variable groups (music-albums-dev / music-albums-prod) with the required variables, then queue .azure-pipelines/main-ci-cd.yml with parameters:
targetEnvironment:devorproddeployInfra:falseby default (set totrueto deploy/update infrastructure)
See Infrastructure Guide for full details on modules, variable groups, dev vs prod differences, and pipelines.
/_health- General health status/_health/live- Liveness probe/_health/ready- Readiness probe (checks database)
Build Docker Image:
docker build -t music-albums-api .