Skip to content

fernandotonacoder/music-albums-api

Repository files navigation

Music Albums API

Build Status Azure Container Apps Docker Bicep

.NET Aspire Dapper PostgreSQL OpenTelemetry Scalar JWT License: MIT

Music Albums REST API in .NET 10 / C#, with Dapper and PostgreSQL. Locally orchestrated by .NET Aspire; containerized with Docker, published to the GitHub Container Registry (GHCR), and deployed to Azure Container Apps through Bicep's Infrastructure as Code (IaC) and a multi-stage Azure Pipelines CI/CD — with app and infrastructure deploys gated by manual approval; a scheduled GitHub Actions workflow prunes old GHCR images. Quality is enforced through unit and integration tests, code coverage, and SonarQube quality gates (Cloud + self-hosted Server). Development follows GitHub Flow — all changes go through PRs (direct push to main is not allowed), CI required, squash merge enforced.

SonarQube Cloud main SonarQube Server main (self-hosted on Azure)
Quality gate Quality gate (server)
Security Rating Security Rating (server)
Vulnerabilities N/A — MQR mode (use Security Issues)
N/A — Standard mode (use Vulnerabilities) Security Issues (server)
N/A — free tier limitation Security Hotspots (server)
Reliability Rating Reliability Rating (server)
Bugs N/A — MQR mode (use Reliability Issues)
N/A — Standard mode (use Bugs) Reliability Issues (server)
Maintainability Rating Maintainability Rating (server)
Technical Debt Technical Debt (server)
Code Smells N/A — MQR mode (use Maintainability Issues)
N/A — Standard mode (use Code Smells) Maintainability Issues (server)
N/A — coverage not uploaded to SonarQube Cloud Coverage (server)
Duplicated Lines (%) Duplicated Lines (%) (server)
Lines of Code Lines of Code (server)

This project is a monolith with a pragmatic Layered Architecture, organized by technical concerns:

  • MusicAlbums.Api (Presentation): MVC Controllers, auth handlers, request/response mapping, health checks, and OpenAPI / Scalar configuration.
  • MusicAlbums.Application (Business & Data): Core business logic (Services), data access (Repositories & Database), domain models, and input validation (Validators).
  • MusicAlbums.Contracts (HTTP Contracts): Request and Response DTOs that define the API's public interface.
  • MusicAlbums.ServiceDefaults (Shared Infrastructure): Cross-cutting runtime concerns — OpenTelemetry instrumentation, service discovery, HTTP client resilience. Referenced by both the API and the Identity API via builder.AddServiceDefaults(), and runs in both local and cloud — only the telemetry exporter changes (OTLP to the Aspire dashboard locally, Azure Monitor to Application Insights in production).

One additional project handles local orchestration only:

  • MusicAlbums.AppHost.NET Aspire orchestrator. Declares the local dev topology (PostgreSQL, the API, the Identity API helper) and is invoked by aspire start. Local development only — not built into the Docker image, not deployed to the cloud.

🌐 Live Demo

Development environment. Demo may scale to zero when idle — the first request can take a few seconds.

Scalar API Reference

The API reference UI was initially built on Swagger UI (Swashbuckle) and later migrated to Scalar on top of .NET 10's built-in Microsoft.AspNetCore.OpenApi (OpenAPI 3.1).

📚 Documentation

🚀 Local Development

Aspire is the local orchestrator. It brings up the API, the Identity API helper, and a persistent PostgreSQL container in one go — from the CLI (aspire start) or via F5 in your IDE.

See Aspire Local Dev for first-time setup, the daily workflow, supported IDEs, and the OpenTelemetry observability setup.

Local orchestration (Aspire Resources Graph)

Aspire Resources Graph

☁️ Cloud Deployment (Azure Container Apps)

Dev Prod
Azure Resource Group — Dev Azure Resource Group — Prod

Two Azure Pipelines drive the cloud: .azure-pipelines/main-ci-cd.yml for the main API and infrastructure, and .azure-pipelines/optional-identity-api.yml for the Identity API helper.

Azure Pipeline — main-ci-cd

Identity API (optional helper)

The Identity API is a JWT token generator for testing. It is deployed into the same resource group as the main API and shares its Container Apps Environment, but its infrastructure is managed by its own pipeline so it can be deployed/destroyed independently.

Azure Pipeline — optional-identity-api

See Infrastructure for the deployment model and dev vs prod differences, and CI/CD for pipeline parameters, service connections, and variable groups.

🩺 Health endpoints

  • /_health/live - liveness probe (process is up; no dependency checks)
  • /_health/ready - readiness probe (checks database connectivity)

⭐ Star this repo if you find it useful!

Made with ❤️ by Fernando Tona WebsiteLinkedInGitHub

About

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

Resources

License

Contributing

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors