Skip to content

DI Refactor: Azure.Mcp.Tools.AppService#1900

Merged
conniey merged 6 commits intomainfrom
copilot/refactor-appservice-dependency-injection
Mar 17, 2026
Merged

DI Refactor: Azure.Mcp.Tools.AppService#1900
conniey merged 6 commits intomainfrom
copilot/refactor-appservice-dependency-injection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

  • Refactor AppService commands to use constructor DI
  • Update unit tests to pass IAppServiceService directly to constructors
  • Add AppServiceSetup to CommandFactoryHelpers.cs (Step 4)
  • Add changelog entry (Step 5)
  • Fix imports ordering in CommandFactoryHelpers.cs (AppLens before AppService)
Original prompt

This section details on the original issue you should resolve

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

Refactor Azure.Mcp.Tools.AppService 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} = AppService.

An example PR is: #1815</issue_description>

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.

…ice commands

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor Azure.Mcp.Tools.AppService for dependency injection DI Refactor: Azure.Mcp.Tools.AppService Mar 2, 2026
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Comment thread servers/Azure.Mcp.Server/changelog-entries/1772482309825.yaml
@conniey conniey marked this pull request as ready for review March 10, 2026 23:17
@conniey conniey requested review from a team and KarishmaGhiya as code owners March 10, 2026 23:17
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

Refactors the AppService tool’s commands to use constructor dependency injection for IAppServiceService (instead of resolving via CommandContext.GetService<T>()), improving testability and aligning with the broader DI migration tracked in #158.

Changes:

  • Updated 4 AppService commands to accept IAppServiceService via constructor injection and use it during execution.
  • Simplified AppService unit tests to pass IAppServiceService directly to command constructors (removing ServiceProvider wiring for GetService<T>()).
  • Updated core unit test command factory helpers to include AppServiceSetup, and added a changelog entry documenting the change.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.AppService/src/Commands/Webapp/WebappGetCommand.cs Injects IAppServiceService via constructor and uses it in ExecuteAsync.
tools/Azure.Mcp.Tools.AppService/src/Commands/Database/DatabaseAddCommand.cs Injects IAppServiceService via constructor and uses it in ExecuteAsync.
tools/Azure.Mcp.Tools.AppService/src/Commands/Webapp/Settings/AppSettingsGetCommand.cs Injects IAppServiceService via constructor and uses it in ExecuteAsync.
tools/Azure.Mcp.Tools.AppService/src/Commands/Webapp/Settings/AppSettingsUpdateCommand.cs Injects IAppServiceService via constructor and uses it in ExecuteAsync.
tools/Azure.Mcp.Tools.AppService/tests/Azure.Mcp.Tools.AppService.UnitTests/Commands/Webapp/WebappGetCommandTests.cs Updates tests to construct the command with IAppServiceService directly.
tools/Azure.Mcp.Tools.AppService/tests/Azure.Mcp.Tools.AppService.UnitTests/Commands/Database/DatabaseAddCommandTests.cs Updates tests to use injected IAppServiceService and a minimal CommandContext.
tools/Azure.Mcp.Tools.AppService/tests/Azure.Mcp.Tools.AppService.UnitTests/Commands/Webapp/Settings/AppSettingsGetCommandTests.cs Updates tests to construct the command with IAppServiceService directly.
tools/Azure.Mcp.Tools.AppService/tests/Azure.Mcp.Tools.AppService.UnitTests/Commands/Webapp/Settings/AppSettingsUpdateCommandTests.cs Updates tests to construct the command with IAppServiceService directly.
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/CommandFactoryHelpers.cs Adds AppServiceSetup so factory-based tests include AppService commands.
servers/Azure.Mcp.Server/changelog-entries/1772482309825.yaml Documents the testability/DI improvement in the server changelog.

@conniey
Copy link
Copy Markdown
Member

conniey commented Mar 16, 2026

@copilot There is an build error. Please fix this by running dotnet format on Microsoft.Mcp.slnx

/mnt/vss/_work/1/s/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/CommandFactoryHelpers.cs(1,1): error IMPORTS: Fix imports ordering. [/mnt/vss/_work/1/s/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Azure.Mcp.Core.UnitTests.csproj]
❌ dotnet format detected formatting issues.
Please run 'dotnet format "/mnt/vss/_work/1/s/Microsoft.Mcp.slnx"' to fix the issues and then try committing again.

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot There is an build error. Please fix this by running dotnet format on Microsoft.Mcp.slnx

/mnt/vss/_work/1/s/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/CommandFactory...

Fixed in e6ae5d6. Moved using Azure.Mcp.Tools.AppLens; before using Azure.Mcp.Tools.AppService; to restore alphabetical ordering in the imports.

Copilot AI requested a review from conniey March 16, 2026 17:57
@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure MCP Server Mar 16, 2026
@conniey conniey merged commit 77686e5 into main Mar 17, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Azure MCP Server Mar 17, 2026
@conniey conniey deleted the copilot/refactor-appservice-dependency-injection branch March 17, 2026 00:28
colbytimm pushed a commit to colbytimm/microsoft-mcp that referenced this pull request Apr 20, 2026
* Initial plan

* DI refactor: inject IAppServiceService via constructor in all AppService commands

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* Add AppServiceSetup to CommandFactoryHelpers and add changelog entry

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* Add PR number.

* fix: fix imports ordering in CommandFactoryHelpers.cs

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

4 participants