Skip to content

[PS] Migrate MySQL module to autorest v4#28784

Open
JoyerJin wants to merge 8 commits intomainfrom
joyer/mysql-migrate-v4
Open

[PS] Migrate MySQL module to autorest v4#28784
JoyerJin wants to merge 8 commits intomainfrom
joyer/mysql-migrate-v4

Conversation

@JoyerJin
Copy link
Copy Markdown
Contributor

@JoyerJin JoyerJin commented Nov 3, 2025

Description

Preannouncement PR:

  1. [PS] Mysql module migration autorest v4 breaking change announcement #28788
  2. [BC]MySQL Update Release Date to May 2026 #29120

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

@JoyerJin JoyerJin marked this pull request as ready for review November 3, 2025 04:38
Copilot AI review requested due to automatic review settings November 3, 2025 04:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request removes support for Azure Database for MySQL single-server cmdlets and focuses exclusively on Azure Database for MySQL flexible servers. This is a breaking change that removes approximately 20+ legacy cmdlets and introduces several improvements for flexible server management.

Key changes:

  • Removed all single-server cmdlets (e.g., Get-AzMySqlServer, New-AzMySqlServer, Update-AzMySqlConfiguration)
  • Retained and updated flexible server cmdlets
  • Updated module dependencies, output types, and parameter types
  • Added breaking change exception file with 102 documented breaking changes
  • Updated help documentation and tests

Reviewed Changes

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

Show a summary per file
File Description
src/MySql/MySql/ChangeLog.md Added breaking change notice with reference link
src/MySql/MySql/Az.MySql.psd1 Removed single-server cmdlets from exports; updated Az.Accounts dependency to 5.3.0
tools/StaticAnalysis/Exceptions/Az.MySql/BreakingChangeIssues.csv Added 102 breaking change exception entries documenting removed cmdlets and API changes
Multiple help files Removed documentation for single-server cmdlets; updated output types for flexible server cmdlets
Test files Removed tests for single-server cmdlets; updated flexible server test scenarios
src/MySql/MySql.Autorest/test/utils.ps1 Simplified test setup; improved password handling
Various .md files Updated parameter types from enums to strings; removed "To construct" notes for InputObject parameters

@@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Improved user experience and consistency. This may introduce breaking changes. Please refer to [here](https://go.microsoft.com/fwlink/?linkid=2340249).
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The changelog entry is too vague for users. It should explicitly state that single-server cmdlets have been removed and list the major breaking changes. Users need to understand what specific cmdlets are no longer available and what alternatives they should use. Consider adding bullet points listing the removed cmdlet categories (e.g., "Removed single-server cmdlets: Get-AzMySqlServer, New-AzMySqlServer, Update-AzMySqlConfiguration, etc.") and guidance to migrate to flexible server cmdlets.

Copilot generated this review using guidance from repository custom instructions.
@Pan-Qi Pan-Qi marked this pull request as draft January 8, 2026 06:19
@Pan-Qi Pan-Qi added Contains Breaking Change This PR contains breaking change autorest v4 migration pr migrating module from generated by autorest.powershell v3 to v4 labels Jan 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 9, 2026

To the author of the pull request,
This PR was labeled "Contains Breaking Change" because breaking changes have been detected by the static analysis pipeline.

  • According to our policy, breaking changes can only take place during major release and they must be preannounced.
  • Please follow our guide on the detailed steps.
  • Required: Please fill in the task below to facilitate our contact,you will receive notifications related to breaking changes.

@JunKai-v JunKai-v force-pushed the joyer/mysql-migrate-v4 branch from 8f1485f to 4770c2d Compare January 20, 2026 01:22
Copilot AI review requested due to automatic review settings January 20, 2026 01:33
@isra-fel
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 138 out of 217 changed files in this pull request and generated 2 comments.

@@ -8,7 +8,7 @@ schema: 2.0.0
# New-AzMySqlFlexibleServerDatabase

## SYNOPSIS
Creates a new database or updates an existing database.
Create a new database or create an existing database.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The SYNOPSIS has a grammatical error. "Create a new database or create an existing database" should be "Create a new database or update an existing database" (or just "Creates a new database or updates an existing database").

Copilot uses AI. Check for mistakes.
@@ -27,7 +48,7 @@ New-AzMySqlFlexibleServerDatabase -InputObject <IMySqlIdentity> [-Charset <Strin
```

## DESCRIPTION
Creates a new database or updates an existing database.
Create a new database or create an existing database.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The DESCRIPTION has the same grammatical error as the SYNOPSIS. "Create a new database or create an existing database" should be "Creates a new database or updates an existing database".

Copilot uses AI. Check for mistakes.
@JunKai-v JunKai-v marked this pull request as ready for review January 20, 2026 02:27
@NoriZC
Copy link
Copy Markdown
Contributor

NoriZC commented Mar 30, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings April 8, 2026 02:33
@VeryEarly
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 138 out of 217 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (1)

src/MySql/MySql.Autorest/custom/Update-AzMySqlFlexibleServer.ps1:82

  • Update-AzMySqlFlexibleServer no longer normalizes -HighAvailability into the internal field used by New-AzMySqlFlexibleServer (HighAvailabilityMode). This introduces inconsistent request shaping between create and update paths. Please confirm what the generated internal cmdlet expects and keep the mapping consistent across both cmdlets.
        [Parameter(HelpMessage = 'Enable or disable high availability feature.  Default value is Disabled. Default: Disabled.')]
        [Microsoft.Azure.PowerShell.Cmdlets.MySql.PSArgumentCompleterAttribute("Disabled", "ZoneRedundant", "SameZone")]
        [Validateset('ZoneRedundant', 'SameZone', 'Disabled')]
        [Alias('HaEnabled')]
        [System.String]
        ${HighAvailability},

        [Parameter(HelpMessage='Backup retention days for the server. Day count is between 7 and 35.')]

Comment on lines +101 to +105
# Create the test Vnet
write-host "Deploy Vnet template"
New-AzDeployment -Mode Incremental -TemplateFile .\test\deployment-templates\virtual-network\template.json -TemplateParameterFile .\test\deployment-templates\virtual-network\parameters.json -Name vn -ResourceGroupName $resourceGroup

Install-Module -Name SimplySQL -Scope CurrentUser -Force
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

New-AzDeployment uses Windows-style relative paths (.\test\...). These test helpers are typically run under PowerShell on multiple OSes; prefer Join-Path (or Resolve-Path) to build the template paths so the script works cross-platform.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to 22
## Upcoming Release
* Improved user experience and consistency. This may introduce breaking changes. Please refer to [here](https://go.microsoft.com/fwlink/?linkid=2340249).

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The changelog entry is too vague for users (it doesn’t say what actually changed in Az.MySql), and the link text "here" is non-descriptive. Please describe the user-visible impact (e.g., migration to AutoRest v4, cmdlet/parameter changes) and, when applicable, reference the related breaking-change announcement PRs/issues (e.g., [#28788], [#29120]).

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 12

## SYNOPSIS
Creates a new database or updates an existing database.
Create a new database or create an existing database.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The synopsis/description "Create a new database or create an existing database" is incorrect and confusing (it implies creating an existing resource). This should describe the actual behavior (create or update an existing database) in user-facing terms.

Copilot uses AI. Check for mistakes.
Comment on lines 39 to 43
Creates a new MySQL flexible server.

### [New-AzMySqlFlexibleServerDatabase](New-AzMySqlFlexibleServerDatabase.md)
Creates a new database or updates an existing database.
Create a new database or create an existing database.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The cmdlet description for New-AzMySqlFlexibleServerDatabase reads "Create a new database or create an existing database", which is grammatically incorrect and misleading. Update it to reflect the real behavior (create or update an existing database).

Copilot uses AI. Check for mistakes.
Comment on lines +153 to +159
Write-Host $PSBoundParameters
$Server = Az.MySql.private\Get-AzMySqlFlexibleServer_GetViaIdentity @PSBoundParameters
}
else {
$SubscriptionId = (Get-AzContext).Subscription.Id
$PSBoundParameters['SubscriptionId'] = $SubscriptionId
Write-Host $PSBoundParameters
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Write-Host $PSBoundParameters adds noisy output and can inadvertently expose values passed to the cmdlet. Prefer Write-Verbose (or remove entirely) and avoid printing the full bound-parameter hashtable.

Suggested change
Write-Host $PSBoundParameters
$Server = Az.MySql.private\Get-AzMySqlFlexibleServer_GetViaIdentity @PSBoundParameters
}
else {
$SubscriptionId = (Get-AzContext).Subscription.Id
$PSBoundParameters['SubscriptionId'] = $SubscriptionId
Write-Host $PSBoundParameters
Write-Verbose "Resolving MySQL flexible server using the provided input object."
$Server = Az.MySql.private\Get-AzMySqlFlexibleServer_GetViaIdentity @PSBoundParameters
}
else {
$SubscriptionId = (Get-AzContext).Subscription.Id
$PSBoundParameters['SubscriptionId'] = $SubscriptionId
Write-Verbose "Resolving MySQL flexible server using the provided parameters and current subscription context."

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +23
$flexibleServerName = 'mysql-flexible-test-400'

Describe 'Test-AzMySqlFlexibleServerConnect' -Tag 'LiveOnly' {
It 'Create' {
New-AzMySqlFlexibleServer -Name $flexibleServerName -ResourceGroupName $env.resourceGroup -AdministratorUserName mysql_test -AdministratorLoginPassword ($env.password | ConvertTo-SecureString -AsPlainText -Force) -Location $env.location -SkuTier GeneralPurpose -Sku Standard_D2ads_v5 -PublicAccess All
}

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The test uses a hard-coded server name (mysql-flexible-test-400). This can cause collisions across parallel runs or repeated local executions and may leave orphaned resources if the test fails mid-run. Prefer generating a unique name (e.g., from $env/random suffix) and ensure cleanup runs in AfterAll/finally so resources are deleted even on failure.

Copilot uses AI. Check for mistakes.
try {
if ($PSBoundParameters.ContainsKey('StorageInMb')) {
$PSBoundParameters.StorageSizeGb = [Math]::floor($PSBoundParameters['StorageInMb'] / 1024)
$gb = [int]([Math]::Ceiling($PSBoundParameters['StorageInMb'] / 1024))
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Update-AzMySqlFlexibleServer now rounds StorageInMb up with Ceiling, while New-AzMySqlFlexibleServer still rounds down with Floor. This makes -StorageInMb behave differently between create vs update for non-1024-aligned values. Please align the conversion logic (and document the rounding behavior) to avoid surprising users.

Suggested change
$gb = [int]([Math]::Ceiling($PSBoundParameters['StorageInMb'] / 1024))
# Keep StorageInMb to StorageSizeGb conversion consistent with New-AzMySqlFlexibleServer.
# When the input is not a multiple of 1024 MB, round down to the nearest whole GB.
$gb = [int]([Math]::Floor($PSBoundParameters['StorageInMb'] / 1024))

Copilot uses AI. Check for mistakes.

[Parameter(HelpMessage='The tier of the particular SKU. Accepted values: Burstable, GeneralPurpose, Memory Optimized. Default: Burstable.')]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.MySql.Support.SkuTier])]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.PSArgumentCompleterAttribute("Burstable", "GeneralPurpose", "MemoryOptimized")]
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

-SkuTier is now a plain System.String with only an argument completer, which removes the input validation that New-AzMySqlFlexibleServer provides via ValidateSet. Consider adding a ValidateSet('Burstable','GeneralPurpose','MemoryOptimized') here as well so invalid tier values are caught early and behavior is consistent across cmdlets.

Suggested change
[Microsoft.Azure.PowerShell.Cmdlets.MySql.PSArgumentCompleterAttribute("Burstable", "GeneralPurpose", "MemoryOptimized")]
[Microsoft.Azure.PowerShell.Cmdlets.MySql.PSArgumentCompleterAttribute("Burstable", "GeneralPurpose", "MemoryOptimized")]
[ValidateSet('Burstable', 'GeneralPurpose', 'MemoryOptimized')]

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +108
# Create the test Vnet
write-host "Deploy Vnet template"
New-AzDeployment -Mode Incremental -TemplateFile .\test\deployment-templates\virtual-network\template.json -TemplateParameterFile .\test\deployment-templates\virtual-network\parameters.json -Name vn -ResourceGroupName $resourceGroup

Install-Module -Name SimplySQL -Scope CurrentUser -Force

write-host "New-AzMySqlServer -Name $serverName -ResourceGroupName $resourceGroup -Location $location -AdministratorUserName mysql_test -AdministratorLoginPassword $password -Sku $Sku"
New-AzMySqlServer -Name $serverName -ResourceGroupName $resourceGroup -Location $location -AdministratorUserName mysql_test -AdministratorLoginPassword $password -Sku $Sku
}
write-host "New-AzMySqlFlexibleServer -Name $flexibleServerName -ResourceGroupName $resourceGroup -AdministratorUserName mysql_test -AdministratorLoginPassword $password -PublicAccess none -Location $location -SkuTier GeneralPurpose -Sku Standard_D2ads_v5"
New-AzMySqlFlexibleServer -Name $flexibleServerName -ResourceGroupName $resourceGroup -AdministratorUserName mysql_test -AdministratorLoginPassword ($password | ConvertTo-SecureString -AsPlainText -Force) -PublicAccess none -Location $location -SkuTier GeneralPurpose -Sku Standard_D2ads_v5
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

setupEnv now always deploys the VNet template and runs Install-Module SimplySQL. Installing modules at test/runtime can be slow and requires PSGallery connectivity; and always deploying infra can increase test cost/time unexpectedly. Consider gating these steps (e.g., only for record/live, or only if the module/template isn’t already present) and avoid Install-Module in automated runs.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +27
Describe 'Test-AzMySqlFlexibleServerConnect' -Tag 'LiveOnly' {
It 'Create' {
New-AzMySqlFlexibleServer -Name $flexibleServerName -ResourceGroupName $env.resourceGroup -AdministratorUserName mysql_test -AdministratorLoginPassword ($env.password | ConvertTo-SecureString -AsPlainText -Force) -Location $env.location -SkuTier GeneralPurpose -Sku Standard_D2ads_v5 -PublicAccess All
}

It 'Test' {
{
Test-AzMySqlFlexibleServerConnect -ResourceGroupName $env.resourceGroup -ServerName $flexibleServerName -AdministratorLoginPassword ($env.password | ConvertTo-SecureString -AsPlainText -Force)
} | Should -Not -Throw
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

These LiveOnly tests rely on SimplySQL being installed, but the test file no longer installs it (and the cmdlet currently exits if SimplySQL is missing). To reduce flakiness for live runs, consider installing SimplySQL in a BeforeAll/setup step for this suite (or explicitly skipping with a clear message when the dependency isn’t available).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autorest v4 migration pr migrating module from generated by autorest.powershell v3 to v4 Contains Breaking Change This PR contains breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants