Overview
Stats.CreateAzureCdnWarehouseReports is a .NET Framework 4.7.2 console application that runs as a NuGet Jobs scheduled worker. Its sole responsibility is to produce the stats-totals.json report — a lightweight JSON snapshot of the NuGet Gallery’s aggregate package counts — and write it to one or more Azure Blob Storage containers.
The report captures three values:
The
downloads field is present in the JSON model (GalleryTotalsData) but is not populated by the SQL query in this job. It remains 0 in the emitted report. Download counts are sourced from a different pipeline.Role in the System
Statistics Pipeline
Sits at the reporting end of the NuGet statistics pipeline. Upstream jobs (CDN log processing, warehouse ETL) feed the Gallery database; this job surfaces summary counts for public consumption.
Gallery Front-End Feed
The
stats-totals.json blob is read by the NuGet Gallery web application to display headline numbers (total packages, unique packages) on the site homepage and API endpoints.Multi-Target Publishing
Supports writing the same report to a primary CDN storage account and an optional secondary storage account, enabling mirroring across environments without running the job twice.
Scheduled Execution
Bootstrapped via
NuGet.Jobs.JobRunner, which handles scheduling, logging lifecycle, and Application Insights integration inherited from the shared jobs framework.Key Files and Classes
Dependencies
NuGet Package References
Internal Project References
Framework / SDK Implicit Dependencies
Notable Patterns and Implementation Details
Managed Identity support — Storage account authentication detects whether
StorageMsiConfiguration.UseManagedIdentity is set. When true, a TokenCredential is resolved from DI and used with the blob endpoint URI; otherwise, the value in config is treated as a connection string. Both paths share the same retry policy.Dual-write for gallery totals — The
AdditionalGalleryTotalsStorageAccount / AdditionalGalleryTotalsStorageContainerName configuration pair is optional. When provided, the report is written to both accounts independently, with per-target error isolation (one failure does not abort the other write).