Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
507d84c
Refactor network commands and validation logic
nachoalonsoportillo Apr 15, 2026
324c635
Fix validation and error handling for PostgreSQL flexible server crea…
nachoalonsoportillo Apr 16, 2026
4361752
Update src/azure-cli/azure/cli/command_modules/postgresql/utils/valid…
nachoalonsoportillo Apr 16, 2026
910152a
Fix validation checks for sourceServerResourceId in PostgreSQL flexib…
nachoalonsoportillo Apr 16, 2026
c280a5b
Merge branch 'implement-new-behavior-with-network-components' of http…
nachoalonsoportillo Apr 16, 2026
d711788
Improve public access range validation by adding error handling for I…
nachoalonsoportillo Apr 16, 2026
f06130b
Refactor error messages in subnet validation for clarity and consistency
nachoalonsoportillo Apr 16, 2026
a22592e
Fix validation for subnet names and update import for CLIError
nachoalonsoportillo Apr 16, 2026
1a1be43
Merge branch 'dev' into implement-new-behavior-with-network-components
nachoalonsoportillo Apr 16, 2026
4b285c0
Fix index tuning and autonomous tuning tests to check for 'top' value…
nachoalonsoportillo Apr 16, 2026
66479e5
Refactor code structure for improved readability and maintainability
nachoalonsoportillo Apr 16, 2026
830eac7
New recordings
nachoalonsoportillo Apr 16, 2026
49d8778
Refactor comments in PostgreSQL flexible server VNet management tests…
nachoalonsoportillo Apr 17, 2026
5478476
Merge branch 'dev' into implement-new-behavior-with-network-components
nachoalonsoportillo Apr 29, 2026
32dca31
Recorded failing test
nachoalonsoportillo May 6, 2026
a0b69da
Merge branch 'dev' into implement-new-behavior-with-network-components
nachoalonsoportillo May 6, 2026
6ae3cd6
Merge branch 'dev' into implement-new-behavior-with-network-components
nachoalonsoportillo May 7, 2026
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 @@ -10,32 +10,6 @@
register_other_breaking_change
)

NETWORK_RESOURCE_BREAKING_CHANGE_MESSAGE = (
'This command will stop creating new network resources or altering existing ones which are required '
'for the server to function, such as virtual networks, subnets, IP ranges, etc. It will instead '
'require users to provide the necessary network resources created beforehand using the corresponding '
'commands from the `az network` module.'
)


def _register_network_resource_breaking_change(command_name):
register_other_breaking_change(command_name, message=NETWORK_RESOURCE_BREAKING_CHANGE_MESSAGE)
register_argument_deprecate(command_name, '--address-prefixes')
register_argument_deprecate(command_name, '--subnet-prefixes')


# These commands will stop creating or altering required network resources and will instead require
# users to provide those resources up front using the corresponding `az network` commands.
# Parameters --address-prefixes and --subnet-prefixes will also be deprecated for these commands as part of this change.
for network_command in (
'postgres flexible-server create',
'postgres flexible-server replica create',
'postgres flexible-server restore',
'postgres flexible-server geo-restore',
'postgres flexible-server revive-dropped'):
_register_network_resource_breaking_change(network_command)


# High availability command argument changes
register_argument_deprecate('postgres flexible-server create', '--high-availability', redirect='--zonal-resiliency')
register_argument_deprecate('postgres flexible-server update', '--high-availability', redirect='--zonal-resiliency')
Expand Down
459 changes: 227 additions & 232 deletions src/azure-cli/azure/cli/command_modules/postgresql/_help.py

Large diffs are not rendered by default.

78 changes: 28 additions & 50 deletions src/azure-cli/azure/cli/command_modules/postgresql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _flexible_server_params(command_group):

migration_id_arg_type = CLIArgumentType(
metavar='NAME',
help="ID of the migration.",
help="Identifier of the migration.",
local_context_attribute=LocalContextAttribute(
name='migration_id',
actions=[LocalContextAction.SET, LocalContextAction.GET],
Expand Down Expand Up @@ -174,20 +174,22 @@ def _flexible_server_params(command_group):
storage_type_arg_type = CLIArgumentType(
arg_type=get_enum_type(['PremiumV2_LRS', 'Premium_LRS']),
options_list=['--storage-type'],
help='Storage type for the server. Allowed values are Premium_LRS and PremiumV2_LRS. Default value is Premium_LRS.'
'Must set iops and throughput if using PremiumV2_LRS.'
help='Storage type for the server. Allowed values are Premium_LRS and PremiumV2_LRS. '
'Default value is Premium_LRS. 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.'
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.'
)

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 is for the new server to match storage type of the source server.'
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 All @@ -203,30 +205,17 @@ def _flexible_server_params(command_group):

vnet_arg_type = CLIArgumentType(
options_list=['--vnet'],
help='Name or ID of a new or existing virtual network. '
'If you want to use a vnet from different resource group or subscription, '
'please provide a resource ID. The name must be between 2 to 64 characters. '
help='Name or identifier of an existing virtual network. '
'If you want to use a vnet from a different resource group or subscription, '
'please provide a resource identifier. The name must be between 2 to 64 characters. '
'The name must begin with a letter or number, end with a letter, number or underscore, '
'and may contain only letters, numbers, underscores, periods, or hyphens.'
)

vnet_address_prefix_arg_type = CLIArgumentType(
options_list=['--address-prefixes'],
help='The IP address prefix to use when creating a new virtual network in CIDR format. '
'Default value is 10.0.0.0/16.'
)

subnet_arg_type = CLIArgumentType(
options_list=['--subnet'],
help='Name or resource ID of a new or existing subnet. '
'If you want to use a subnet from different resource group or subscription, please provide resource ID instead of name. '
'Please note that the subnet will be delegated to flexibleServers. '
'After delegation, this subnet cannot be used for any other type of Azure resources.'
)

subnet_address_prefix_arg_type = CLIArgumentType(
options_list=['--subnet-prefixes'],
help='The subnet IP address prefix to use when creating a new subnet in CIDR format. Default value is 10.0.0.0/24.'
help='Name or identifier of an existing subnet. '
'If you want to use a subnet from a different resource group or subscription, please provide its resource identifier instead of name.'
Comment thread
nachoalonsoportillo marked this conversation as resolved.
)

zone_arg_type = CLIArgumentType(
Expand Down Expand Up @@ -282,23 +271,22 @@ def _flexible_server_params(command_group):

private_dns_zone_arguments_arg_type = CLIArgumentType(
options_list=['--private-dns-zone'],
help='This parameter only applies for a server with private access. '
'The name or id of new or existing private dns zone. '
'You can use the private dns zone from same resource group, different resource group, or different subscription. '
'If you want to use a zone from different resource group or subscription, please provide resource Id. '
'CLI creates a new private dns zone within the same resource group as virtual network if not provided by users.'
help='This parameter only applies for a server with private access and is required when using --vnet or --subnet. '
'The name or resource identifier of an existing private DNS zone. '
'You can use a private DNS zone from the same resource group, a different resource group, or a different subscription. '
'If you want to use a zone from a different resource group or subscription, please provide its resource identifier.'
)

restore_point_in_time_arg_type = CLIArgumentType(
options_list=['--restore-time'],
default=get_current_time(),
help='The point in time in UTC to restore from (ISO8601 format), e.g., 2017-04-26T02:10:00+00:00'
help='The point in time in UTC to restore from (ISO8601 format), e.g., 2026-03-22T18:20:22+00:00 '
'The default value is set to current time.'
)

source_server_arg_type = CLIArgumentType(
options_list=['--source-server'],
help='The name or resource ID of the source server to restore from.'
help='The name or resource identifier of the source server to restore from.'
)

geo_redundant_backup_arg_type = CLIArgumentType(
Expand All @@ -309,30 +297,30 @@ def _flexible_server_params(command_group):

identity_arg_type = CLIArgumentType(
options_list=['--identity'],
help='The name or resource ID of the user assigned identity for data encryption.',
help='The name or resource identifier of the user assigned identity for data encryption.',
validator=validate_byok_identity
)

backup_identity_arg_type = CLIArgumentType(
options_list=['--backup-identity'],
help='The name or resource ID of the geo backup user identity for data encryption. The identity needs to be in the same region as the backup region.',
help='The name or resource identifier of the geo backup user identity for data encryption. The identity needs to be in the same region as the backup region.',
validator=validate_byok_identity
)

key_arg_type = CLIArgumentType(
options_list=['--key'],
help='The resource ID of the primary keyvault key for data encryption.'
help='The resource identifier of the primary keyvault key for data encryption.'
)

backup_key_arg_type = CLIArgumentType(
options_list=['--backup-key'],
help='The resource ID of the geo backup keyvault key for data encryption. The key needs to be in the same region as the backup region.'
help='The resource identifier of the geo backup keyvault key for data encryption. The key needs to be in the same region as the backup region.'
)

identities_arg_type = CLIArgumentType(
options_list=['--identity', '-n'],
nargs='+',
help='Space-separated names or ID\'s of identities.',
help='Space-separated names or identifiers of identities.',
validator=validate_identities
)

Expand Down Expand Up @@ -397,7 +385,7 @@ def _flexible_server_params(command_group):
c.argument('version', arg_type=version_arg_type)
c.argument('backup_retention', default=7, arg_type=pg_backup_retention_arg_type)
c.argument('microsoft_entra_auth', default='Disabled', arg_type=microsoft_entra_auth_arg_type)
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique identifier of the Microsoft Entra administrator.')
c.argument('admin_name', options_list=['--admin-display-name', '-m'], help='Display name of the Microsoft Entra administrator user or group.')
c.argument('admin_type', options_list=['--admin-type', '-t'],
arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Microsoft Entra administrator.')
Expand All @@ -423,9 +411,7 @@ def _flexible_server_params(command_group):
c.argument('high_availability', arg_type=high_availability_arg_type, default="Disabled")
c.argument('public_access', arg_type=public_access_create_arg_type)
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
c.argument('zone', zone_arg_type)
c.argument('tags', tags_type)
Expand All @@ -443,9 +429,7 @@ def _flexible_server_params(command_group):
c.argument('restore_point_in_time', arg_type=restore_point_in_time_arg_type)
c.argument('source_server', arg_type=source_server_arg_type)
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
c.argument('zone', arg_type=zone_arg_type)
c.argument('yes', arg_type=yes_arg_type)
Expand All @@ -461,9 +445,7 @@ def _flexible_server_params(command_group):
c.argument('sku_name', arg_type=sku_name_arg_type)
c.argument('source_server', arg_type=source_server_arg_type)
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
c.argument('zone', arg_type=zone_arg_type)
c.argument('yes', arg_type=yes_arg_type)
Expand All @@ -479,9 +461,7 @@ def _flexible_server_params(command_group):
c.argument('sku_name', arg_type=sku_name_arg_type)
c.argument('source_server', arg_type=source_server_arg_type)
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
c.argument('zone', arg_type=zone_arg_type)
c.argument('yes', arg_type=yes_arg_type)
Expand Down Expand Up @@ -622,8 +602,6 @@ def _flexible_server_params(command_group):
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
c.argument('byok_key', arg_type=key_arg_type)
c.argument('byok_identity', arg_type=identity_arg_type)
c.argument('tier', arg_type=tier_arg_type)
Expand Down Expand Up @@ -673,7 +651,7 @@ def _flexible_server_params(command_group):
c.argument('identities', arg_type=identities_arg_type)

with self.argument_context('{} flexible-server identity show'.format(command_group)) as c:
c.argument('identity', options_list=['--identity', '-n'], help='Name or ID of identity to show.', validator=validate_identity)
c.argument('identity', options_list=['--identity', '-n'], help='Name or identifier of identity to show.', validator=validate_identity)

with self.argument_context('{} flexible-server identity update'.format(command_group)) as c:
c.argument('system_assigned', options_list=['--system-assigned'], arg_type=get_enum_type(['Enabled', 'Disabled']),
Expand All @@ -696,12 +674,12 @@ def _flexible_server_params(command_group):

for scope in ['create', 'show', 'delete', 'wait']:
with self.argument_context('{} flexible-server microsoft-entra-admin {}'.format(command_group, scope)) as c:
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
c.argument('sid', options_list=['--object-id', '-i'], help='The unique identifier of the Microsoft Entra administrator.')

with self.argument_context('{} flexible-server microsoft-entra-admin create'.format(command_group)) as c:
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Microsoft Entra administrator user or group.')
c.argument('principal_type', options_list=['--type', '-t'], default='User', arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Microsoft Entra administrator.')
c.argument('identity', help='Name or ID of identity used for Microsoft Entra Authentication.', validator=validate_identity)
c.argument('identity', help='Name or identifier of identity used for Microsoft Entra Authentication.', validator=validate_identity)

# server advanced threat protection settings
for scope in ['update', 'show']:
Expand Down Expand Up @@ -738,7 +716,7 @@ def _flexible_server_params(command_group):
help='The name of the private endpoint connection associated with the Server. '
'Required if --id is not specified')
c.extra('connection_id', options_list=['--id'], required=False,
help='The ID of the private endpoint connection associated with the Server. '
help='The identifier of the private endpoint connection associated with the Server. '
'If specified --server-name/-s and --name/-n, this should be omitted.')
if scope == "approve" or scope == "reject":
c.argument('description', help='Comments for {} operation.'.format(scope), required=True)
Expand Down
Loading
Loading