Skip to content

Update AKS tool to use BaseAzureResourceService#2852

Open
msalaman wants to merge 3 commits into
mainfrom
masalama/AKSServiceBug
Open

Update AKS tool to use BaseAzureResourceService#2852
msalaman wants to merge 3 commits into
mainfrom
masalama/AKSServiceBug

Conversation

@msalaman

@msalaman msalaman commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Update AKS tool to use BaseAzureResourceService to make use of Resource Graph functionality

GitHub issue number?

467

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • (No changelog entry as this is an internal refactor) Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated (dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

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

This PR updates the AKS tool’s cluster enumeration path to use BaseAzureResourceService (Azure Resource Graph) instead of ARM SDK enumeration, enabling Resource Graph-backed querying and shifting cluster modeling to JSON-based projection.

Changes:

  • Switched AksService inheritance to BaseAzureResourceService and migrated GetClusters/single-cluster retrieval to Resource Graph queries.
  • Replaced ARM SDK-based Cluster mapping with a JSON (JsonElement) projection/mapping pipeline and supporting parsing helpers.
Show a summary per file
File Description
tools/Azure.Mcp.Tools.Aks/src/Services/AksService.cs Migrates cluster retrieval to Resource Graph and introduces JSON-based mapping for Cluster (and nested profiles).

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment on lines +60 to +64
var result = await ExecuteResourceQueryAsync(
"Microsoft.ContainerService/managedClusters",
resourceGroup,
subscription,
retryPolicy,
Comment on lines +281 to +287
if (props.TryGetProperty("oidcIssuerProfile", out var oidcEl))
{
cluster.OidcIssuerProfile = new()
{
NetworkPlugin = data.NetworkProfile?.NetworkPlugin?.ToString(),
NetworkPluginMode = data.NetworkProfile?.NetworkPluginMode?.ToString(),
NetworkPolicy = data.NetworkProfile?.NetworkPolicy?.ToString(),
NetworkDataplane = data.NetworkProfile?.NetworkDataplane?.ToString(),
LoadBalancerSku = data.NetworkProfile?.LoadBalancerSku?.ToString(),
LoadBalancerProfile = data.NetworkProfile?.LoadBalancerProfile is null ? null : new()
{
ManagedOutboundIPCount = data.NetworkProfile?.LoadBalancerProfile?.ManagedOutboundIPs?.Count,
EffectiveOutboundIPs = data.NetworkProfile?.LoadBalancerProfile?.EffectiveOutboundIPs?.Select(e => new EffectiveOutboundIPReference() { Id = e.Id?.ToString() }).ToList(),
BackendPoolType = data.NetworkProfile?.LoadBalancerProfile?.BackendPoolType?.ToString()
},
PodCidr = data.NetworkProfile?.PodCidr,
ServiceCidr = data.NetworkProfile?.ServiceCidr,
DnsServiceIP = data.NetworkProfile?.DnsServiceIP?.ToString(),
OutboundType = data.NetworkProfile?.OutboundType?.ToString(),
PodCidrs = data.NetworkProfile?.PodCidrs?.ToList(),
ServiceCidrs = data.NetworkProfile?.ServiceCidrs?.ToList(),
IpFamilies = data.NetworkProfile?.IPFamilies?.Select(f => f.ToString()).ToList()
},
WindowsProfile = data.WindowsProfile is null ? null : new() { AdminUsername = data.WindowsProfile.AdminUsername },
ServicePrincipalProfile = data.ServicePrincipalProfile is null ? null : new() { ClientId = data.ServicePrincipalProfile.ClientId },
AutoUpgradeProfile = data.AutoUpgradeProfile is null ? null : new()
Enabled = TryGetNullableBool(oidcEl, "enabled"),
IssuerUrl = oidcEl.TryGetProperty("issuerURL", out var iuEl) ? iuEl.GetString() : null,
};
}

private static Cluster ConvertToClusterModel(ContainerServiceManagedClusterResource clusterResource)
private static Cluster ConvertToClusterFromJson(JsonElement item)

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.

Would it be possible for this method to leverage converting the JsonElement using JsonSerializer.Deserialize if we get the property names and types properly aligned? There is a lot of logic going on here, which makes understanding what's going on more complicated and likely to be error prone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants