feat(compute): unified VM/VMSS create with discovery tools and VMSS Flex default#2654
feat(compute): unified VM/VMSS create with discovery tools and VMSS Flex default#2654deankroker wants to merge 5 commits into
Conversation
2aa4d75 to
2129264
Compare
|
@microsoft-github-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Pull request overview
This PR reframes the Azure MCP Compute tool to support a guided VM/VMSS create flow: it adds read-only discovery commands (SKUs, images, quota, region recommendations) and introduces a unified compute create entry point that defaults to VMSS Flex with an explicit --single-instance fallback to a standalone VM.
Changes:
- Added four discovery commands (
list-skus,list-images,check-quota,recommend-region) and corresponding models/options, plus source-generated JSON coverage and unit tests. - Introduced unified
compute createcommand that dispatches to VMSS Flex by default or to VM create when--single-instanceis set (with updated live tests). - Added VMSS create networking parity options (
--public-ip-address,--network-security-group,--no-public-ip,--source-address-prefix) and implemented VMSS NIC/NSG/public-IP-config wiring inComputeService.
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with write access 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.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vmss/VmssCreateCommandTests.cs | Adds unit tests to validate new VMSS networking options are passed through to the service. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmSkuListCommandTests.cs | New unit tests for SKU discovery command, including vmScaleSetsSupported serialization. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmRegionRecommendCommandTests.cs | New unit tests for region recommendation command and AZ-weighting ordering behavior. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmQuotaCheckCommandTests.cs | New unit tests for quota discovery command, including VMSS-related quota dimensions. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/Vm/VmImageListCommandTests.cs | New unit tests for image discovery command, including shared gallery enumeration flag. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.UnitTests/UnifiedCreateCommandTests.cs | New unit tests validating unified create dispatch (VMSS default vs --single-instance) and validation rules. |
| tools/Azure.Mcp.Tools.Compute/tests/Azure.Mcp.Tools.Compute.LiveTests/ComputeCommandTests.cs | Adds live smoke tests for compute_create default and single-instance modes. |
| tools/Azure.Mcp.Tools.Compute/src/Services/IComputeService.cs | Extends service contract with discovery APIs and new VMSS networking parameters. |
| tools/Azure.Mcp.Tools.Compute/src/Services/ComputeService.cs | Implements discovery operations, retail price lookup via named HttpClient, region scoring, and VMSS networking parity. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vmss/VmssCreateOptions.cs | Adds VMSS create option properties for public IP/NSG/no-public-ip/source prefix. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vm/VmSkuListOptions.cs | New options type for SKU discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vm/VmRegionRecommendOptions.cs | New options type for region recommendation command. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vm/VmQuotaCheckOptions.cs | New options type for quota discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Options/Vm/VmImageListOptions.cs | New options type for image discovery command (including shared gallery flag). |
| tools/Azure.Mcp.Tools.Compute/src/Options/UnifiedCreateOptions.cs | New superset options surface for unified create (VMSS-first schema + SingleInstance). |
| tools/Azure.Mcp.Tools.Compute/src/Options/ComputeOptionDefinitions.cs | Adds CLI options for discovery commands and unified create; updates option descriptions for VM/VMSS language. |
| tools/Azure.Mcp.Tools.Compute/src/Models/VmSkuInfo.cs | New model for SKU discovery results (capabilities + optional pricing + VMSS support). |
| tools/Azure.Mcp.Tools.Compute/src/Models/VmRegionRecommendation.cs | New model for ranked region recommendations with rationale. |
| tools/Azure.Mcp.Tools.Compute/src/Models/VmQuotaInfo.cs | New model for quota lines including derived availability/percent/status fields. |
| tools/Azure.Mcp.Tools.Compute/src/Models/VmImageInfo.cs | New model for alias/marketplace/shared-gallery image candidates. |
| tools/Azure.Mcp.Tools.Compute/src/ComputeSetup.cs | Registers new commands, adds named HttpClient, and exposes discovery commands at both compute and compute vm. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vmss/VmssCreateCommand.cs | Wires new VMSS networking options into command binding and service call. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmSkuListCommand.cs | Implements list-skus discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmRegionRecommendCommand.cs | Implements recommend-region discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmQuotaCheckCommand.cs | Implements check-quota discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmImageListCommand.cs | Implements list-images discovery command. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/Vm/VmCreateCommand.cs | Updates VM create command description to position it as a non-scalable fallback. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/UnifiedCreateCommand.cs | Adds unified compute create command with validation and dispatch to VMSS or VM create. |
| tools/Azure.Mcp.Tools.Compute/src/Commands/ComputeJsonContext.cs | Extends source-generated JSON context for new commands/results/models. |
| servers/Azure.Mcp.Server/changelog-entries/azure-compute-team-guided-vm-create-tools.yml | Adds changelog entry for the new guided-create discovery tools. |
Adds four read-only compute commands that let agents present real choices
before invoking compute_vm_create or compute_vmss_create:
- vm list-skus filter the SKU catalog by region, vCPU, memory,
family prefix; optional retail pricing augmentation
- vm list-images resolve a marketplace alias or publisher/offer/sku
to a current URN
- vm check-quota report current vCPU usage vs subscription limit per
family, with optional requested-vCPU headroom check
- vm recommend-region rank regions for a workload hint, with optional
geography filter and AZ-required constraint
These were previously gaps that forced agents to either guess values or
fall back to az CLI shell-outs. The Azure Compute skill in
GitHub-Copilot-for-Azure consumes them as its Step 4 validation gates.
Includes unit tests for each command and a single shared Features Added
changelog entry. Pricing in list-skus uses the unauthenticated Azure
Retail Prices API; all four commands inherit standard ComputeService
RBAC and retry policy plumbing.
Pushes VMSS Flex as the recommended default for new compute and treats a
single standalone VM as the fallback for non-scalable workloads. Existing
`compute vm …` and `compute vmss …` commands keep working unchanged.
- Reframe descriptions: ComputeSetup root group, VM create, VMSS create,
and shared option text now lead with VMSS Flex; anti-funneling lines
are removed.
- New top-level `compute create` unified entry point that dispatches to
VMSS Flex by default and falls back to a single VM with --single-instance.
- Register list-skus / list-images / check-quota / recommend-region under
the root `compute` group as discovery aliases (same class instances —
no new IDs).
- Reach VMSS create network parity with VM create: --public-ip-address,
--network-security-group, --no-public-ip, --source-address-prefix.
- Discovery enrichments to power the unified guided flow:
* VmSkuInfo gains VMScaleSetsSupported (so the create flow can filter
out SKUs that can't back a Flex scale set).
* list-images gains --include-shared-gallery for Compute Gallery image
enumeration with their resource IDs.
* check-quota surfaces VMSS dimensions: scale set count, low-priority
cores, and availability set count.
* recommend-region weights AZ-rich regions higher when the workload
hint mentions scale / HA / production / vmss and AZs are required.
- Unit tests for every new behavior plus two live-test smoke cases for
`compute_create` (vmss-flex default and single-vm fallback).
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
- Clarify tool-name references in Copilot-flagged doc strings (ComputeService, ComputeOptionDefinitions) and a misleading test comment (VmImageListCommandTests). - Hand-apply dotnet format whitespace fixes in ComputeService.cs to satisfy IDE0011/csharp_prefer_braces — split single-line `if (...) stmt;` patterns across vCPU/memory/disk capability parsing, retail-prices fetch, image-alias enumeration, marketplace versions, and shared-gallery enumeration. - Fix xUnit1051 analyzer errors in UnifiedCreateCommandTests by replacing CancellationToken positional defaults with TestContext.Current.CancellationToken for responsive test cancellation. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
0dd627f to
61ea784
Compare
…overy aliases MCP-surface smoke coverage for the area registration: verifies that the new top-level `compute create` (UnifiedCreateCommand) and the four discovery aliases (list-skus, list-images, check-quota, recommend-region) are reachable directly under the `compute` root group; that the back-compat `vm`/`vmss`/`disk` subgroups still resolve; that the discovery aliases share class instances with their `vm/` subgroup counterparts (so CommandMetadata.Id GUIDs stay stable and MCP clients don't see two distinct tools for the same operation); and that the group description still leads with the VMSS Flex recommendation. Modeled on ServiceBusSetupTests. Closes the "MCP client smoke" gate from the PR test plan — exercises the wiring without requiring a running MCP server or the pinned 10.0.201 SDK locally. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
dotnet format flagged three single-line if-statements in RecommendVmRegionsAsync where the body sat on the same line as the condition. Break each body onto its own line so the repo's source analysis gate passes. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
TL;DR
Adds four read-only Azure discovery tools and makes VMSS Flex the default shape for a new
compute createcommand. Purely additive — every existingcompute vmandcompute vmssinvocation works unchanged.compute create+ 4 discovery aliases at thecomputeroot)compute vmss creategains network parity flagsWhy
Agents asked to "create a VM" today guess SKUs, images, quotas, and regions before calling create — and they pick a single VM when the user almost always wants something that can scale. This PR adds the discovery tools that let the agent verify before committing, and shifts the default so VMSS Flex is the recommended path while single VM remains an explicit fallback.
What changed
Commit 1 —
feat(compute): add guided VM/VMSS create discovery toolsFour new read-only discovery tools under
compute vm. All use the Azure SDK directly (noazCLI subprocess), so they inherit auth, RBAC, and retry behavior from the MCP host:list-skus— VM sizes available in a region, with vCPU / memory / AZ / AcceleratedNetworking filterslist-images— marketplace images by alias or publisher/offer/skucheck-quota— current vs limit on the SKU family the caller is about to deploy intorecommend-region— region scoring with workload-hint, geography, and AZ requirementsThese are intended as validation gates immediately before a create call.
Commit 2 —
feat(compute): reframe VMSS Flex as the default + unified compute createcompute createtop-level command. Defaults to VMSS Flex, 2 instances, AZ-spread.--single-instancefalls back to a single VM.computeso agents don't have to descend intovm/.compute vmss create. Adds--public-ip-address,--network-security-group,--no-public-ip, and--source-address-prefixso picking the recommended path no longer silently downgrades networking.list-skussurfacesvmScaleSetsSupportedper SKUlist-imagesadds--include-shared-galleryfor Compute Gallery image refscheck-quotasurfaces VMSS-relevant dimensions (virtualMachineScaleSets,lowPriorityCores,availabilitySets)recommend-regionweighs AZ-rich regions more heavily on scale / HA / production / vmss hintsCustomer experience
Ask the agent for a VM → discovery tools confirm a SKU exists in the region with quota headroom and scale-set support, in an AZ-rich region →
compute createreturns a Flex scale set, 2 instances, AZ-spread, with public IP / NSG support (not just defaults). Only need one box?--single-instance. Need fifty next quarter? Same resource, no rebuild.Sample agent flow
Test plan
VmSkuListCommandTests,VmImageListCommandTests,VmQuotaCheckCommandTests,VmRegionRecommendCommandTests), including the new--include-shared-galleryflag, VMSS quota dimensions, and AZ-weighting heuristicUnifiedCreateCommandcovering both the VMSS Flex default and the--single-instancefallbackShould_create_with_unified_create_defaults_to_vmss_flexandShould_create_with_unified_create_single_instance_falls_back_to_vminAzure.Mcp.Tools.Compute.Tests/ComputeCommandTests.cslines 1509–1584)ComputeSetupTestsinAzure.Mcp.Tools.Compute.Tests/ComputeSetupTests.csasserts that:compute createregisters at the rootlist-skus,list-images,check-quota,recommend-region) resolve directly undercomputeand share class instances with theircompute vmcounterparts (stableCommandMetadata.IdGUIDs)vm/vmss/disksubgroups still resolve