Fix SQL subscription name-to-GUID resolution#2861
Open
vcolin7 wants to merge 3 commits into
Open
Conversation
Resolve the subscription through ISubscriptionService in GetSqlServerResourceAsync, RenameDatabaseAsync, ListServersAsync, and CreateServerAsync instead of building a SubscriptionResource directly from the raw subscription value, which failed with a cryptic ARM error when a subscription display name was passed instead of a GUID. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Azure SQL tools’ subscription handling so callers can pass either a subscription display name or a GUID, aligning SQL behavior with other toolsets by resolving subscriptions through ISubscriptionService.
Changes:
- Updated
SqlServiceto resolve subscriptions viaISubscriptionService.GetSubscription(...)in the affected SQL operations (server show/list/create and db rename), and to use the resolved subscription ID when constructing SQL DB resource identifiers for rename. - Added unit tests intended to validate that each affected method routes subscription resolution through
ISubscriptionServicewhen given a display name. - Added an Azure MCP Server changelog entry describing the bug fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Sql/tests/Azure.Mcp.Tools.Sql.Tests/Services/SqlServiceTests.cs | Adds unit tests to assert the service resolves subscriptions via ISubscriptionService. |
| tools/Azure.Mcp.Tools.Sql/src/Services/SqlService.cs | Switches SQL operations from direct subscription identifier construction to subscription resolution through ISubscriptionService. |
| servers/Azure.Mcp.Server/changelog-entries/vcolin7-sql-subscription-resolution.yaml | Documents the SQL subscription name-to-GUID resolution fix in the server changelog entry format. |
The subscription name-to-GUID fix (#449/#453) adds a GET /subscriptions/{id} ARM call via ISubscriptionService before navigating to the SQL server. The prior recordings lacked that interaction, causing playback mismatches for the four tests that route through GetSqlServerResourceAsync. Re-recorded them and updated the assets tag. Re-recorded: ListSqlServerEntraAdmins, ListSqlServerFirewallRules, CreateFirewallRule, DeleteFirewallRule. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
vcolin7
added a commit
that referenced
this pull request
Jun 16, 2026
…ols (#448, #452) The ARM SDK refactor of ListDatabasesAsync and GetElasticPoolsAsync routed the subscription through SubscriptionResource.CreateResourceIdentifier, which only accepts a subscription GUID. This regressed the prior Resource Graph behavior where a subscription name also worked, as flagged by Copilot review on PR #2865. Scope the fix narrowly to just these two list methods by resolving the subscription via ISubscriptionService before navigating the ARM hierarchy. The shared GetSqlServerResourceAsync helper and the server/firewall/entra-admin/create/rename paths are intentionally left unchanged to avoid overlapping with PR #2861. The new ResolveSubscriptionIdAsync helper skips the extra ARM request when the value is already a subscription ID, so existing recordings remain valid. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
What does this PR do?
Several Azure SQL operations failed with a cryptic ARM error when a user passed a subscription display name instead of a subscription GUID. The root cause: four methods in
SqlServicebuilt aSubscriptionResourcedirectly from the rawsubscriptionargument viaSubscriptionResource.CreateResourceIdentifier(subscription), which only accepts a GUID.This PR resolves the subscription through the injected
ISubscriptionService(the same pattern the Storage and Cosmos toolsets use), so both subscription IDs and names work consistently.Affected methods:
GetSqlServerResourceAsyncListServersAsyncCreateServerAsyncRenameDatabaseAsyncAdded
SqlServiceTestswith four unit tests proving each method resolves throughISubscriptionServicewhen given a display name.GitHub issue number?
Fixes #449
Fixes #453
Pre-merge Checklist
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess to the repo need to validate the contents of this PR before leaving a comment with the text/azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.