Skip to content

fernandotonacoder/music-albums-api

Repository files navigation

Music Albums API

Build Status Azure Container Apps Docker Bicep

.NET PostgreSQL Swagger JWT License: MIT

Music Albums REST API written in C# / .NET Core, with Dapper and PostgreSQL

🌐 Live Demo

A live version of this API is deployed on Azure Container Apps:

🔗 Swagger UI

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.

� Documentation

�🚀 Local Setup

Secrets are stored in User Secrets (outside the repo, never committed).

First Time Setup:

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 values

Note: 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;"

Run:

docker-compose up -d  # Start database
cd src/MusicAlbums.Api
dotnet run

🔍 View Your Secrets:

# 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.json

Find <UserSecretsId> in MusicAlbums.Api.csproj or Identity.Api.csproj.

☁️ Cloud Deployment (Azure Container Apps)

Setup

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: dev or prod
  • deployInfra: false by default (set to true to deploy/update infrastructure)

See Infrastructure Guide for full details on modules, variable groups, dev vs prod differences, and pipelines.

Health Endpoints

  • /_health - General health status
  • /_health/live - Liveness probe
  • /_health/ready - Readiness probe (checks database)

Build Docker Image:

docker build -t music-albums-api .

About

Music Albums REST API written in C# / .NET Core, with Dapper and PostgreSQL, deployed as an Azure Container App

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors