Skip to content

Fix Get-AzAksCluster -Id ignoring subscription in resource ID - #29929

Open
a0x1ab with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-get-azakscluster-subscription-issue
Open

Fix Get-AzAksCluster -Id ignoring subscription in resource ID#29929
a0x1ab with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-get-azakscluster-subscription-issue

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Get-AzAksCluster -Id was ignoring the subscription embedded in the supplied resource ID and always routing the API call to the current context subscription — causing NotFound errors or silently returning a wrong cluster when the same resource group/name existed in the current subscription.

Root cause: The IdParameterSet case parsed the ResourceIdentifier for ResourceGroupName and ResourceName but never used .Subscription. The ContainerServiceClient was always initialized from DefaultProfile.DefaultContext.

Changes

  • GetAzureRmAks.cs: In the IdParameterSet case, extract the subscription from the parsed resource ID and set Client.SubscriptionId before making the API call:
case IdParameterSet:
    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);
  • ChangeLog.md: Document the fix under Upcoming Release.

Copilot AI requested review from Copilot and removed request for Copilot July 30, 2026 08:52
@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-client-tools-agent

Copy link
Copy Markdown

Live test skipped

⏭️ Skipping the live test for this revision because no changed test file was found under a <Service>.Test project (src/<Service>/<Service>.Test/**/*.cs|*.ps1).

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
Copilot AI requested review from Copilot and removed request for Copilot July 30, 2026 08:57
Copilot AI changed the title [WIP] Fix Get-AzAksCluster to respect subscription in resource ID Fix Get-AzAksCluster -Id ignoring subscription in resource ID Jul 30, 2026
Copilot AI requested a review from a0x1ab July 30, 2026 08:58
@azure-client-tools-agent

Copy link
Copy Markdown

Live test skipped

⏭️ Skipping the live test for this revision because no changed test file was found under a <Service>.Test project (src/<Service>/<Service>.Test/**/*.cs|*.ps1).

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

@azure-client-tools-agent azure-client-tools-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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|*.ps1 files, 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-client-tools-agent
azure-client-tools-agent Bot marked this pull request as ready for review July 30, 2026 09:01
Copilot AI review requested due to automatic review settings July 30, 2026 09:01
@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.SubscriptionId from the subscription segment in the -Id resource ID when present
  • Add changelog entry describing the -Id subscription 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

Comment on lines 90 to 95
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);
Comment thread src/Aks/Aks/ChangeLog.md
Comment on lines 20 to +23
## 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-AzAksCluster -Id appears to ignore subscription in resource ID and uses current context subscription

3 participants