Skip to content

DI Refactor: Azure.Mcp.Tools.Compute#1914

Merged
conniey merged 4 commits intomainfrom
copilot/refactor-azure-mcp-tools-compute
Mar 11, 2026
Merged

DI Refactor: Azure.Mcp.Tools.Compute#1914
conniey merged 4 commits intomainfrom
copilot/refactor-azure-mcp-tools-compute

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

  • Add IComputeService constructor injection to VmGetCommand and VmssGetCommand
  • Update VmGetCommandTests and VmssGetCommandTests to pass mock service via constructor
  • Add changelog entry with PR number (DI Refactor: Azure.Mcp.Tools.Compute #1914)
Original prompt

This section details on the original issue you should resolve

<issue_title>DI Refactor: Azure.Mcp.Tools.Compute</issue_title>
<issue_description>## Summary

Refactor Azure.Mcp.Tools.Compute to use constructor dependency injection instead of resolving services via context.GetService<T>() in ExecuteAsync.

This is a sub-issue of #158.

Instructions

Follow the algorithm described in tools/di-refactor-plan.md with {ToolArea} = Compute.

An example PR is: #1815
</issue_description>

<agent_instructions>After creating the PR, please double check Step 5 was done. In particular, make sure New-ChangelogEntry.ps1 is executed so the CHANGELOG entry is correct.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 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.

…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
Comment thread servers/Azure.Mcp.Server/changelog-entries/1772567866615.yaml
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
@conniey conniey marked this pull request as ready for review March 10, 2026 23:25
@conniey conniey requested review from a team and g2vinay as code owners March 10, 2026 23:25
@conniey conniey enabled auto-merge (squash) March 10, 2026 23:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IComputeService via primary constructors in VmGetCommand and VmssGetCommand, removing context.GetService<IComputeService>() usage in ExecuteAsync.
  • Update corresponding unit tests to pass a mocked IComputeService directly 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.

Comment thread tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmGetCommand.cs
@conniey conniey merged commit 6d8cb7e into main Mar 11, 2026
29 checks passed
@conniey conniey deleted the copilot/refactor-azure-mcp-tools-compute branch March 11, 2026 00:12
@github-project-automation github-project-automation bot moved this from Untriaged to Done in Azure MCP Server Mar 11, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DI Refactor: Azure.Mcp.Tools.Compute

4 participants