Skip to content

[ResilienceManagement] Add create commands (namespace: resilience)#2990

Open
LavishSingal wants to merge 4 commits into
microsoft:mainfrom
LavishSingal:user/lsingal/resilience-create-v2
Open

[ResilienceManagement] Add create commands (namespace: resilience)#2990
LavishSingal wants to merge 4 commits into
microsoft:mainfrom
LavishSingal:user/lsingal/resilience-create-v2

Conversation

@LavishSingal

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the authoring (create-or-update) commands to the Azure Resilience Management toolset (Azure.Mcp.Tools.ResilienceManagement, command namespace resilience).

This is PR 2 of the rollout plan in #2894 — building on the read-only surface delivered in #2948. It adds create commands across the goal and usage-plan command groups, reusing the toolset plumbing established in PR 1 (IAreaSetup, BaseAzureResourceService, non-standard serviceGroup path-parameter handling, parameter shapes, telemetry, and recorded-test infrastructure). Lifecycle/action commands follow in PR 3.

All commands are create-or-update (ReadOnly = false, Destructive = false, Idempotent = true). Each returns the created/updated resource's details.

Commands added:

  • Goal
    • resilience goal template create (GoalTemplates_CreateOrUpdate)
    • resilience goal assignment create (GoalAssignments_CreateOrUpdate) — takes a separate --goal-template-service-group so the assigned template can live in a different service group than the assignment
  • Usage Plan
    • resilience usageplan create (UsagePlans_CreateOrUpdate)
    • resilience usageplan enrollment create (Enrollments_CreateOrUpdate)

Also includes unit tests, recorded live tests (goal template/assignment, usage plan, enrollment), README/command docs/e2e prompts, and a changelog entry.

GitHub issue number?

Part of #2894

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
    • 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

Adds authoring (create-or-update) commands to the existing Azure Resilience Management toolset (Azure.Mcp.Tools.ResilienceManagement, namespace resilience), extending the read-only surface from the prior onboarding PR with resource creation/update capabilities plus tests and docs updates.

Changes:

  • Added create commands (goal template, goal assignment, usage plan, usage plan enrollment) with corresponding options, JSON context registrations, and DI/command-group wiring.
  • Implemented create-or-update service methods in ResilienceManagementService using ARM SDK CreateOrUpdateAsync.
  • Updated recorded live test infrastructure (Bicep + post-deploy), live tests, README, e2e prompts, command docs, and changelog entry.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.ResilienceManagement/tests/test-resources.bicep Adds isolated RG/service-group outputs for create live tests.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/test-resources-post.ps1 Provisions isolated RG/service-group for create live tests via REST/Az cmdlets.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/UsagePlans/UsagePlanCreateCommandTests.cs Unit tests for resilience usageplan create.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/UsagePlans/Enrollments/UsagePlanEnrollmentCreateCommandTests.cs Unit tests for resilience usageplan enrollment create.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/Goals/Templates/GoalTemplateCreateCommandTests.cs Unit tests for resilience goal template create.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/Goals/Assignments/GoalAssignmentCreateCommandTests.cs Unit tests for resilience goal assignment create.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/ResilienceManagementCommandTests.cs Adds recorded live tests validating create flows end-to-end.
tools/Azure.Mcp.Tools.ResilienceManagement/tests/Azure.Mcp.Tools.ResilienceManagement.Tests/assets.json Updates recorded-test assets tag.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Services/ResilienceManagementService.cs Adds create-or-update implementations for goal templates/assignments, usage plans, and enrollments.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Services/IResilienceManagementService.cs Extends service interface with create methods.
tools/Azure.Mcp.Tools.ResilienceManagement/src/ResilienceManagementSetup.cs Registers new commands and adds them to command groups.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Options/UsagePlans/UsagePlanCreateOption.cs Adds options model for usage plan create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Options/UsagePlans/Enrollments/UsagePlanEnrollmentCreateOption.cs Adds options model for enrollment create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Options/Goals/Templates/GoalTemplateCreateOption.cs Adds options model for goal template create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Options/Goals/Assignments/GoalAssignmentCreateOption.cs Adds options model for goal assignment create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Commands/UsagePlans/UsagePlanCreateCommand.cs New command implementation for usage plan create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Commands/UsagePlans/Enrollments/UsagePlanEnrollmentCreateCommand.cs New command implementation for enrollment create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Commands/Goals/Templates/GoalTemplateCreateCommand.cs New command implementation for goal template create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Commands/Goals/Assignments/GoalAssignmentCreateCommand.cs New command implementation for goal assignment create.
tools/Azure.Mcp.Tools.ResilienceManagement/src/Commands/ResilienceManagementJsonContext.cs Registers new command result models for source-generated JSON serialization.
servers/Azure.Mcp.Server/README.md Adds Resilience Management examples and service list entry.
servers/Azure.Mcp.Server/docs/e2eTestPrompts.md Adds new e2e prompts for create commands.
servers/Azure.Mcp.Server/docs/azmcp-commands.md Adds CLI docs entries for the new commands.
servers/Azure.Mcp.Server/changelog-entries/1782549900000.yaml Adds changelog entries for the new create commands.

Comment on lines +20 to +28
Title = "Create Resilience Usage Plan",
Description = """
Creates a resilience usage plan in the specified resource group with the given plan type, and returns
the created usage plan information including id, name, resource type, location, tags, plan type, and
provisioning state.
""",
Destructive = false,
Idempotent = false,
OpenWorld = false,
Comment on lines +3671 to +3676
# Create a resilience usage plan in a resource group
# ❌ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp resilience usageplan create --subscription <subscription> \
--resource-group <resource-group> \
--usage-plan <usage-plan> \
--plan-type <plan-type>
Comment on lines +135 to +138
# NOTE: this resource group is created outside the test harness's managed resource group and is
# therefore NOT auto-cleaned by teardown; it is named "<rg>-create" for easy manual cleanup.
$location = (Get-AzResourceGroup -Name $ResourceGroupName).Location
New-AzResourceGroup -Name $createResourceGroupName -Location $location -Force | Out-Null
ReadOnly = false,
Secret = false,
LocalRequired = false)]
public sealed class GoalAssignmentCreateCommand(ILogger<GoalAssignmentCreateCommand> logger, IResilienceManagementService resilienceManagementService, ISubscriptionResolver subscriptionResolver)

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.

This command extends from Subscription command, but it doesn't use subscription parameter, does it ?
If not, we should not extend from Subscription command.

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