Convert Moonlight.ApiServer to Azure Functions with .NET 9 and Aspire orchestration #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completely transforms the Moonlight.ApiServer from a traditional ASP.NET Core application with Hangfire background processing into a modern, serverless Azure Functions application using .NET 9's isolated model and .NET Aspire orchestration.
Major Changes
🚀 New Azure Functions Architecture
Created a new
Moonlight.Functionsproject that replaces the existingMoonlight.ApiServer.Runtimewith a fully serverless implementation:🔄 API Endpoint Migration
All existing controllers have been converted to Azure Functions while preserving exact API contracts:
Authentication (
/api/auth):AuthGetSchemes- Get available authentication schemesAuthCheck- Validate user authenticationAuthLogout- Handle user logoutAdministration (
/api/admin/*):AdminGetUsers- List system usersAdminGetUser- Get specific user detailsAdminSystemInfo- System information endpointAdminHealthCheck- Administrative health monitoringFile Management (
/api/admin/system/files/*):FilesListDirectory- Browse directory contentsFilesUpload- File upload functionalityFilesDownload- File download with proper headersFilesDelete- File and directory deletionFrontend Serving (
/):FrontendIndex- Serve main application pageFrontendConfig- Frontend configuration endpoint⏰ Background Jobs Modernization
Replaced Hangfire infrastructure with native Azure Functions timer triggers:
0 0 2 * * *) - Runs at 2 AM UTC daily0 */5 * * * *) - Runs every 5 minutes🏗️ .NET Aspire Integration
Added
Moonlight.Orchestrationproject for modern distributed application management:🔧 Technical Improvements
Modern .NET 9 Patterns:
IHostApplicationBuilderinstead of legacy hosting patternsConfiguration Modernization:
MOONLIGHT_prefixhost.jsonSecurity Enhancements:
AuthorizationLevel.FunctionvsAnonymous)Benefits
💰 Cost & Operations
🔧 Developer Experience
📈 Performance & Reliability
Breaking Changes
None - All existing API endpoints maintain exact compatibility. Clients require no changes.
Migration Path
The new Functions-based architecture is deployed alongside the existing infrastructure:
Moonlight.ApiServer.Runtime(ASP.NET Core + Hangfire)Moonlight.Functions(Azure Functions + Timer triggers)Moonlight.Orchestration(.NET Aspire)Testing
The solution builds successfully and all Functions are properly configured:
Documentation
Added comprehensive
API_CONVERSION_SUMMARY.mddocumenting:This modernization positions Moonlight for cloud-native deployment while maintaining full backward compatibility and significantly improving operational efficiency.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.mscurl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.