Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,16 @@ def _flexible_server_params(command_group):
'Must set iops and throughput if using PremiumV2_LRS.'
)

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.'
)

Comment on lines +183 to +188
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.
storage_type_restore_arg_type = CLIArgumentType(
arg_type=get_enum_type(['PremiumV2_LRS']),
options_list=['--storage-type'],
help='Storage type for the new server. Allowed value is PremiumV2_LRS. Default value is none.'
help='Storage type for the new server. Allowed value is PremiumV2_LRS. Default is for the new server to match storage type of the source server.'
)

performance_tier_arg_type = CLIArgumentType(
Expand Down Expand Up @@ -629,6 +635,7 @@ def _flexible_server_params(command_group):
c.argument('performance_tier', default=None, arg_type=performance_tier_arg_type)
c.argument('yes', arg_type=yes_arg_type)
c.argument('tags', arg_type=tags_type)
c.argument('storage_type', default=None, arg_type=storage_type_replica_arg_type)

with self.argument_context('{} flexible-server replica promote'.format(command_group)) as c:
c.argument('replica_name', arg_type=replica_name_arg_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def flexible_replica_create(cmd, client, resource_group_name, source_server, rep
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):
validate_resource_group(resource_group_name)

Expand Down Expand Up @@ -119,7 +119,7 @@ def flexible_replica_create(cmd, client, resource_group_name, source_server, rep

parameters.sku = postgresql_flexibleservers.models.Sku(name=sku_name, tier=tier)

parameters.storage = postgresql_flexibleservers.models.Storage(storage_size_gb=storage_gb, auto_grow=source_server_object.storage.auto_grow, tier=performance_tier)
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)

Comment on lines +122 to 123
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.
return sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, replica_name, parameters)

Expand Down
Loading