Skip to content

[POSTGRESQL] as postgresql flexible-server replica create: Select storage type PremiumV2_LRS for replica server#33134

Open
nasc17 wants to merge 1 commit intoAzure:devfrom
nasc17:nasc/replicaSSDV2
Open

[POSTGRESQL] as postgresql flexible-server replica create: Select storage type PremiumV2_LRS for replica server#33134
nasc17 wants to merge 1 commit intoAzure:devfrom
nasc17:nasc/replicaSSDV2

Conversation

@nasc17
Copy link
Copy Markdown
Member

@nasc17 nasc17 commented Apr 3, 2026

Related command
as postgresql flexible-server replica create

Description
Users can select to have read replica as PremiumV2_LRS.

Testing Guide
Manual

History Notes
[POSTGRESQL] as postgresql flexible-server replica create: New argument --storage-type to select storage type as PremiumV2_LRS for read replica

@nasc17 nasc17 requested a review from VeryEarly as a code owner April 3, 2026 17:56
Copilot AI review requested due to automatic review settings April 3, 2026 17:56
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 3, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

azure-client-tools-bot-prd bot commented Apr 3, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️postgresql
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd postgres flexible-server replica create cmd postgres flexible-server replica create added parameter storage_type

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 3, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

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

Adds support for selecting Premium SSD v2 storage (PremiumV2_LRS) when creating PostgreSQL Flexible Server read replicas via the as postgresql flexible-server replica create command.

Changes:

  • Adds a new --storage-type argument for flexible-server replica create (currently restricted to PremiumV2_LRS).
  • Passes storage.type through to the SDK Storage model during replica creation.
  • Updates restore --storage-type help text to describe default behavior as “match source server”.

Reviewed changes

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

File Description
src/azure-cli/azure/cli/command_modules/postgresql/commands/replica_commands.py Accepts storage_type for replica create and sends it in the Storage payload.
src/azure-cli/azure/cli/command_modules/postgresql/_params.py Introduces --storage-type for replica create and adjusts restore help text.

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

Comment on lines +122 to 123
parameters.storage = postgresql_flexibleservers.models.Storage(storage_size_gb=storage_gb, auto_grow=source_server_object.storage.auto_grow, tier=performance_tier, type=storage_type)

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

--storage-type PremiumV2_LRS is now accepted, but the request still always copies auto_grow from the primary and always passes performance_tier (storage tier) without any PremiumV2-specific validation. Premium SSD v2 in this module is validated elsewhere to require auto-grow disabled and to disallow performance tiers (and often requires iops/throughput). Consider adding replica-specific validation/normalization when storage_type == 'PremiumV2_LRS' (e.g., enforce/override auto-grow, clear performance_tier, and handle required iops/throughput) before constructing Storage to avoid sending an invalid request that will fail server-side.

Suggested change
parameters.storage = postgresql_flexibleservers.models.Storage(storage_size_gb=storage_gb, auto_grow=source_server_object.storage.auto_grow, tier=performance_tier, type=storage_type)
storage_auto_grow = source_server_object.storage.auto_grow
storage_performance_tier = performance_tier
if storage_type == 'PremiumV2_LRS':
storage_auto_grow = 'Disabled'
storage_performance_tier = None
parameters.storage = postgresql_flexibleservers.models.Storage(storage_size_gb=storage_gb,
auto_grow=storage_auto_grow,
tier=storage_performance_tier,
type=storage_type)

Copilot uses AI. Check for mistakes.
Comment on lines +183 to +188
storage_type_replica_arg_type = CLIArgumentType(
arg_type=get_enum_type(['PremiumV2_LRS']),
options_list=['--storage-type'],
help='Storage type for the read replica. Allowed value is PremiumV2_LRS. Default is for the read replica to match storage type of the primary server.'
)

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Replica create adds --storage-type PremiumV2_LRS, but this command does not currently expose --iops/--throughput (which are required for PremiumV2 in the existing storage validators) and still allows --performance-tier (which PremiumV2 disallows). Either add the missing arguments and hook them into replica validation, or explicitly block incompatible combinations so users don’t hit avoidable service-side validation errors.

Copilot uses AI. Check for mistakes.
Comment on lines 31 to 37
# pylint: disable=too-many-locals
def flexible_replica_create(cmd, client, resource_group_name, source_server, replica_name=None, name=None, zone=None,
location=None, vnet=None, vnet_address_prefix=None, subnet=None,
subnet_address_prefix=None, private_dns_zone_arguments=None, no_wait=False,
byok_identity=None, byok_key=None,
sku_name=None, tier=None,
sku_name=None, tier=None, storage_type=None,
storage_gb=None, performance_tier=None, yes=False, tags=None):
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

New storage_type behavior for replica create is not covered by scenario tests. There are existing replication scenario tests in this module; please add coverage that creates a replica with --storage-type PremiumV2_LRS (and any required related args/expected defaults) and asserts the resulting storage.type (and iops/throughput/autoGrow expectations as applicable).

Copilot uses AI. Check for mistakes.
@nasc17
Copy link
Copy Markdown
Member Author

nasc17 commented Apr 3, 2026

@calvinhzy please trigger checks

@yonzhan yonzhan assigned calvinhzy and unassigned evelyn-ys Apr 3, 2026
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 3, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants