Fix Get-AzAksCluster -Id ignoring subscription in resource ID#29929
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Live test skipped⏭️ Skipping the live test for this revision because no changed test file was found under a The live-test pipeline runs only the scenario/xUnit test files a PR changes, so there is nothing to execute for this commit. This is informational — a regression test is encouraged where it makes sense, but not required. If a test file is added in a later commit, the live test will run automatically. Posted by agent-assist (autonomous bug-fix pipeline). |
When using Get-AzAksCluster -Id with a resource ID containing a different subscription than the current context, the cmdlet was ignoring the subscription from the resource ID and using the current context subscription instead. Fix: Extract the subscription from the resource ID and override Client.SubscriptionId before making the API call in the IdParameterSet case. Fixes #29928
Live test skipped⏭️ Skipping the live test for this revision because no changed test file was found under a The live-test pipeline runs only the scenario/xUnit test files a PR changes, so there is nothing to execute for this commit. This is informational — a regression test is encouraged where it makes sense, but not required. If a test file is added in a later commit, the live test will run automatically. Posted by agent-assist (autonomous bug-fix pipeline). |
There was a problem hiding this comment.
Automated Review Summary
PR: Fix Get-AzAksCluster -Id ignoring subscription in resource ID (fixes #29928)
Status: ✅ Pass
- CI Checks: 1/1 passed, 0 failed, 0 pending.
- Live Test (TestFx
Record): Skipped — this PR does not modify any<Service>.Test/**/*.cs|*.ps1files, so there is no recorded test to run live. This is treated as neutral, not a failure.
No blocking issues found. Moving this PR out of draft for human review.
Posted by agent-assist (autonomous bug-fix pipeline).
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.
Updates Get-AzAksCluster -Id behavior to respect the subscription contained in the provided resource ID (instead of always using the current context subscription), and documents the fix in the changelog.
Changes:
- Set
Client.SubscriptionIdfrom the subscription segment in the-Idresource ID when present - Add changelog entry describing the
-Idsubscription fix and referencing issue #29928
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aks/Aks/Commands/GetAzureRmAks.cs | Uses subscription parsed from resource ID when executing Get by -Id |
| src/Aks/Aks/ChangeLog.md | Documents the fix in “Upcoming Release” notes |
| var resource = new ResourceIdentifier(Id); | ||
| if (!string.IsNullOrEmpty(resource.Subscription)) | ||
| { | ||
| Client.SubscriptionId = Guid.Parse(resource.Subscription); | ||
| } | ||
| var idCluster = Client.ManagedClusters.Get(resource.ResourceGroupName, resource.ResourceName); |
| ## Upcoming Release | ||
| * Fixed `Get-AzAksCluster -Id` ignoring the subscription embedded in the resource ID and using the current context subscription instead | ||
| - The cmdlet now correctly uses the subscription from the provided resource ID | ||
| - Fixed issue [#29928] |
Get-AzAksCluster -Idwas ignoring the subscription embedded in the supplied resource ID and always routing the API call to the current context subscription — causingNotFounderrors or silently returning a wrong cluster when the same resource group/name existed in the current subscription.Root cause: The
IdParameterSetcase parsed theResourceIdentifierforResourceGroupNameandResourceNamebut never used.Subscription. TheContainerServiceClientwas always initialized fromDefaultProfile.DefaultContext.Changes
GetAzureRmAks.cs: In theIdParameterSetcase, extract the subscription from the parsed resource ID and setClient.SubscriptionIdbefore making the API call:ChangeLog.md: Document the fix under Upcoming Release.