Add Inspect operation mode for introspection without activating DCP or Publishers #12072
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.
Summary
Adds a new Inspect operation mode to the Aspire AppHost that enables introspection of the application model without activating DCP (Distributed Control Plane) or Publishers. This mode is useful for scenarios where you need to analyze the application structure, dependencies, and configuration without the overhead and side effects of actually running or publishing the application.
Usage
The Inspect mode can be activated via command-line argument:
Or programmatically:
Behavior
What Inspect Mode Does:
What Inspect Mode Does NOT Do:
Changes
Inspect
valueIsInspectMode
property for convenient mode checking--operation
argument and disable health checks in Inspect modeIsSupported
check to useIsRunMode
instead of!IsPublishMode
to ensure DCP doesn't run in Inspect modeComparison with Other Modes
Design Notes
The implementation leverages existing conditional logic patterns where most services were already conditionally registered based on
IsRunMode
. The only service that needed a fix wasOrchestratorHostService
, which was using!IsPublishMode
and would have incorrectly activated DCP in Inspect mode. The code inDistributedApplication.cs
already had comments anticipating this mode, showing it was part of the original design intent.This is a minimal, backward-compatible change with no breaking changes to existing APIs. All code compiles successfully and follows the repository's established patterns and style guidelines.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.