Merged
Conversation
…tCommand and VmssGetCommand Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor Azure.Mcp.Tools.Compute to use constructor dependency injection
DI Refactor: Azure.Mcp.Tools.Compute
Mar 3, 2026
conniey
reviewed
Mar 10, 2026
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Compute tool’s VM and VMSS “get” commands to use constructor dependency injection for IComputeService instead of resolving it from CommandContext during execution, improving testability and aligning with DI patterns used elsewhere in the repo.
Changes:
- Inject
IComputeServicevia primary constructors inVmGetCommandandVmssGetCommand, removingcontext.GetService<IComputeService>()usage inExecuteAsync. - Update corresponding unit tests to pass a mocked
IComputeServicedirectly into command constructors. - Add a server changelog entry documenting the Compute DI refactor.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmGetCommand.cs | Switches VM get command to constructor-injected IComputeService and updates call sites. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vmss/VmssGetCommand.cs | Switches VMSS get command to constructor-injected IComputeService and updates call sites. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmGetCommandTests.cs | Updates unit tests to construct the command with a mocked compute service. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vmss/VmssGetCommandTests.cs | Updates unit tests to construct the command with a mocked compute service. |
| servers/Azure.Mcp.Server/changelog-entries/1772567866615.yaml | Adds changelog entry for the Compute DI refactor/testability improvement. |
conniey
approved these changes
Mar 10, 2026
KarishmaGhiya
approved these changes
Mar 11, 2026
6 tasks
colbytimm
pushed a commit
to colbytimm/microsoft-mcp
that referenced
this pull request
Apr 20, 2026
* Initial plan * DI Refactor: Compute - inject IComputeService via constructor in VmGetCommand and VmssGetCommand Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> * Add PR number to changelog entry Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> Co-authored-by: Connie Yau <conniey@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
IComputeServiceconstructor injection toVmGetCommandandVmssGetCommandVmGetCommandTestsandVmssGetCommandTeststo pass mock service via constructorOriginal prompt
💡 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.