Skip to content

Feature: Replace all ARM resource read operations with the ARG library to reduce tool size #226

@alzimmermsft

Description

@alzimmermsft

Proposal

This is a proposal to reduce the size of the AzureMCP server.
The Azure.ResourceManager.ResourceGraph library enables retrieval of any ARM resource data, making it a viable replacement for specific Azure.ResourceManager.XXX libraries used in individual tools.

Details

Current Approach

Each tool currently relies on its corresponding .NET management library to list or read Azure resource data. For example, the List AKS Cluster tool uses the Azure.ResourceManager.ContainerService library. If we introduce a new tool, such as one to list MySQL Flexible Servers, we would need to add a dependency on Azure.ResourceManager.MySql.

As more tools are added, the number of Azure management .NET SDKs integrated into the project will grow, leading to a continuous increase in the size of the AzureMCP server.

Proposed Optimization

The Azure.ResourceManager.ResourceGraph (ARG) library supports querying any ARM resource. It can be used to replace the read operations currently handled by individual service-specific libraries. For instance, the List AKS Cluster tool can be refactored to use a Resource Graph query instead of relying on the ContainerService SDK:

"Resources | where type =~ 'Microsoft.ContainerService/managedClusters' | project id, name, type, location, tags, sku, properties"

Libraries to be removed

  • Azure.ResourceManager.ContainerRegistry: 1.42 MB
  • Azure.ResourceManager.ContainerService : 1.27 MB
  • Azure.ResourceManager.AppConfiguration : 541 KB
  • Azure.ResourceManager.Authorization : 858 KB
  • Azure.ResourceManager.CosmosDB : 3.39 MB
  • Azure.ResourceManager.CognitiveServices : 1.26 MB (share with write operation)
  • Azure.ResourceManager.Grafana : 587 KB
  • Azure.ResourceManager.Kusto : 1.01 MB
  • Azure.ResourceManager.LoadTesting : 298 KB (share with write operation)
  • Azure.ResourceManager.OperationalInsights : 1.02 MB
  • Azure.ResourceManager.PostgreSql : 1.57 MB (share with write operation)
  • Azure.ResourceManager.Redis : 669 KB
  • Azure.ResourceManager.RedisEnterprise : 567 KB
  • Azure.ResourceManager.Search : 610 KB
  • Azure.Messaging.ServiceBus : 700 KB
  • Azure.ResourceManager.Sql : 6.41 MB
  • Azure.ResourceManager.Storage : 1.67 MB
  • Azure.ResourceManager.DesktopVirtualization : 1.15 MB
  • Azure.ResourceManager.ApplicationInsights : 852 KB (share with write operation)

Completing all the above changes will reduce the total size by 22+ MB.

Pros & Cons

Pros

Reduced Server Size: Significantly decreases the overall size of the AzureMCP server by minimizing dependencies.
Improved Query Performance: Resource Graph queries are generally faster than service-specific SDK calls.

⚠️ Cons

Latency in Resource Updates: ARG may not reflect real-time changes immediately, leading to potential delays in resource state visibility.
Extra Deserialization Required: No strongly typed models, additional code is needed to parse and deserialize the results.

Metadata

Metadata

Assignees

Labels

Engineering ExcellenceItems required to be resolved before onboarding the "third wave" of azure RPsserver-Azure.McpAzure.Mcp.Servertools-ARMARM Resource Management Group

Projects

Status

In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions