Skip to content

[MySQL Flexible Server] Add --maintenance-batch to flexible-server update#33768

Open
aalishapatro23 wants to merge 4 commits into
Azure:devfrom
aalishapatro23:feature/mysql-maintenance-batch-update
Open

[MySQL Flexible Server] Add --maintenance-batch to flexible-server update#33768
aalishapatro23 wants to merge 4 commits into
Azure:devfrom
aalishapatro23:feature/mysql-maintenance-batch-update

Conversation

@aalishapatro23

@aalishapatro23 aalishapatro23 commented Jul 22, 2026

Copy link
Copy Markdown

Related command
az mysql flexible-server update

Description

Adds a new optional --maintenance-batch parameter to az mysql flexible-server update, allowing customers to set the batch (Default, Batch1, Batch2) of a custom-managed maintenance window.

Previously the CLI could set the maintenance window's day/time (--maintenance-window) but had no way to control batchOfMaintenance, even though the RP and the pinned SDK (azure-mgmt-mysqlflexibleservers==1.1.0b2) already support it via MaintenanceWindow.batch_of_maintenance. Customers who wanted a specific batch had no CLI path (surfaced by a customer case where the batch could not be set/preserved through the CLI).

Behavior:

  • --maintenance-batch is honored only alongside an enabled --maintenance-window. Used alone (or with --maintenance-window Disabled) it raises a clear error.
  • When --maintenance-batch is omitted, the server's existing batch is preserved — the request body is unchanged from today, so existing scripts are unaffected.
  • Disabling the window clears the batch.

This is a CLI-only passthrough change. No SDK bump, no OpenAPI/RP change. It is non-breaking — verified via azdev command-change meta-diff (only an added optional parameter, zero breaking changes).

Testing Guide

Set a custom maintenance window with a specific batch
az mysql flexible-server update -g testGroup -n testserver
--maintenance-window "Fri:13:00" --maintenance-batch Batch2

Update only the window; the existing batch is preserved (omit --maintenance-batch)
az mysql flexible-server update -g testGroup -n testserver
--maintenance-window "Sat:14:00"

Guardrails (both error out):
az mysql flexible-server update -g testGroup -n testserver --maintenance-batch Batch1
az mysql flexible-server update -g testGroup -n testserver
--maintenance-window Disabled --maintenance-batch Batch1

Validation performed:

  • azdev style mysql, azdev linter mysql — pass
  • azdev test mysql — existing tests pass (26 passed / 5 skipped)
  • New scenario test test_mysql_flexible_server_maintenance_batch_mgmt — live recording + playback pass; recording included
  • azdev command-change meta-diff — no breaking changes
  • Manual live test against a real flexible server: batch set to Batch1, then preserved after a window-only update

History Notes
[MySQL Flexible Server] az mysql flexible-server update: Add --maintenance-batch to set the batch (Default, Batch1, Batch2) of the custom-managed maintenance window; existing batch is preserved when omitted

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️mysql
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd mysql flexible-server update cmd mysql flexible-server update added parameter maintenance_batch

Copilot added 3 commits July 22, 2026 10:38
…et/preserve custom maintenance window batch

Adds an optional --maintenance-batch parameter (Default/Batch1/Batch2) to az mysql flexible-server update. When omitted, the existing batchOfMaintenance is preserved; when the maintenance window is disabled the batch is cleared. Wires the SDK MaintenanceWindow.batch_of_maintenance field (already present in azure-mgmt-mysqlflexibleservers 1.1.0b2) through the CLI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f9c96871-4d63-4a60-9622-70bfffb3cc7a
Adds test_mysql_flexible_server_maintenance_batch_mgmt covering: setting the batch on a custom maintenance window, preserving the existing batch when updating the window only, changing the batch explicitly, and the two guardrail error cases. Recording (.yaml) still to be generated live.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f9c96871-4d63-4a60-9622-70bfffb3cc7a
Adds the live recording for test_mysql_flexible_server_maintenance_batch_mgmt so it replays in CI playback. Verified passing in both live (460s) and playback (16s) runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f9c96871-4d63-4a60-9622-70bfffb3cc7a
Copilot AI review requested due to automatic review settings July 22, 2026 13:50
@aalishapatro23
aalishapatro23 requested review from a team as code owners July 22, 2026 13:50
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @aalishapatro23,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-pipelines

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

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Jul 22, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution @aalishapatro23! We will review the pull request and get back to you soon.

@aalishapatro23

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

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 support in the MySQL command module for setting a Flexible Server custom-managed maintenance window “batch” via a new optional --maintenance-batch parameter on az mysql flexible-server update, aligning CLI capabilities with the already-supported SDK/RP property.

Changes:

  • Add --maintenance-batch parameter (Default/Batch1/Batch2) to az mysql flexible-server update and wire it into the update implementation with guardrails.
  • Add a new scenario test covering setting/preserving/changing the maintenance batch and invalid parameter combinations.
  • Update command help and release notes to document the new parameter.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/azure-cli/HISTORY.rst Adds release note entry for the new --maintenance-batch parameter.
src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_scenario.py Adds a new scenario test for maintenance batch behavior and guardrails.
src/azure-cli/azure/cli/command_modules/mysql/custom.py Implements maintenance_batch handling in the flexible server update custom function.
src/azure-cli/azure/cli/command_modules/mysql/_params.py Introduces the --maintenance-batch CLI argument with enum validation.
src/azure-cli/azure/cli/command_modules/mysql/_help.py Adds a help example demonstrating --maintenance-batch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2343 to +2348
# guardrail: --maintenance-batch cannot be combined with disabling the window
self.cmd('{} flexible-server update -g {} -n {} --maintenance-window "Disabled" --maintenance-batch Batch2'
.format(database_engine, resource_group, server_name), expect_failure=True)

self.cmd('{} flexible-server delete -g {} -n {} --yes'
.format(database_engine, resource_group, server_name))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Keeping the scenario focused on the new  --maintenance-batch  parameter and its guardrails. The disable path just clears the field via a thin SDK passthrough, and asserting the exact server-returned value after disable would require verifying RP behavior

@yonzhan

yonzhan commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

mysql

@yonzhan
yonzhan requested a review from Pan-Qi July 22, 2026 22:56
@Pan-Qi

Pan-Qi commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Comment thread src/azure-cli/HISTORY.rst Outdated
* `az keyvault key create`: Add `--external-key-id` to create EKM-backed external keys on Managed HSM (Preview) (#33651)

**MySQL**

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.

Please remove the change in HOSTORY.rst, as will be generated together before release

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — removed the HISTORY.rst change . Thanks!

…ase)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aalishapatro23
aalishapatro23 requested a review from Pan-Qi July 23, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Auto-Assign Auto assign by bot Batch az batch customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants