[POSTGRESQL] as postgresql flexible-server replica create: Select storage type PremiumV2_LRS for replica server#33134
[POSTGRESQL] as postgresql flexible-server replica create: Select storage type PremiumV2_LRS for replica server#33134
as postgresql flexible-server replica create: Select storage type PremiumV2_LRS for replica server#33134Conversation
️✔️AzureCLI-FullTest
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| postgres flexible-server replica create | cmd postgres flexible-server replica create added parameter storage_type |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
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-typeargument forflexible-server replica create(currently restricted toPremiumV2_LRS). - Passes
storage.typethrough to the SDKStoragemodel during replica creation. - Updates restore
--storage-typehelp 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.
| 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) | ||
|
|
There was a problem hiding this comment.
--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.
| 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) |
| 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.' | ||
| ) | ||
|
|
There was a problem hiding this comment.
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.
| # 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): |
There was a problem hiding this comment.
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).
|
@calvinhzy please trigger checks |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Related command
as postgresql flexible-server replica createDescription
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-typeto select storage type as PremiumV2_LRS for read replica