Skip to content

Commit 6b5027d

Browse files
[POSTGRESQL] BREAKING CHANGE: az postgres flexible-server: Refactor network commands and validation logic (#33192)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dbb0e13 commit 6b5027d

42 files changed

Lines changed: 31559 additions & 33692 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/azure-cli/azure/cli/command_modules/postgresql/_breaking_change.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,6 @@
99
register_other_breaking_change
1010
)
1111

12-
NETWORK_RESOURCE_BREAKING_CHANGE_MESSAGE = (
13-
'This command will stop creating new network resources or altering existing ones which are required '
14-
'for the server to function, such as virtual networks, subnets, IP ranges, etc. It will instead '
15-
'require users to provide the necessary network resources created beforehand using the corresponding '
16-
'commands from the `az network` module.'
17-
)
18-
19-
20-
def _register_network_resource_breaking_change(command_name):
21-
register_other_breaking_change(command_name, message=NETWORK_RESOURCE_BREAKING_CHANGE_MESSAGE)
22-
register_argument_deprecate(command_name, '--address-prefixes')
23-
register_argument_deprecate(command_name, '--subnet-prefixes')
24-
25-
26-
# These commands will stop creating or altering required network resources and will instead require
27-
# users to provide those resources up front using the corresponding `az network` commands.
28-
# Parameters --address-prefixes and --subnet-prefixes will also be deprecated for these commands as part of this change.
29-
for network_command in (
30-
'postgres flexible-server create',
31-
'postgres flexible-server replica create',
32-
'postgres flexible-server restore',
33-
'postgres flexible-server geo-restore',
34-
'postgres flexible-server revive-dropped'):
35-
_register_network_resource_breaking_change(network_command)
36-
37-
3812
# High availability command argument changes
3913
register_argument_deprecate('postgres flexible-server create', '--high-availability', redirect='--zonal-resiliency')
4014
register_argument_deprecate('postgres flexible-server update', '--high-availability', redirect='--zonal-resiliency')

src/azure-cli/azure/cli/command_modules/postgresql/_help.py

Lines changed: 218 additions & 223 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/postgresql/_params.py

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _flexible_server_params(command_group):
6161

6262
migration_id_arg_type = CLIArgumentType(
6363
metavar='NAME',
64-
help="ID of the migration.",
64+
help="Identifier of the migration.",
6565
local_context_attribute=LocalContextAttribute(
6666
name='migration_id',
6767
actions=[LocalContextAction.SET, LocalContextAction.GET],
@@ -167,20 +167,22 @@ def _flexible_server_params(command_group):
167167
storage_type_arg_type = CLIArgumentType(
168168
arg_type=get_enum_type(['PremiumV2_LRS', 'Premium_LRS']),
169169
options_list=['--storage-type'],
170-
help='Storage type for the server. Allowed values are Premium_LRS and PremiumV2_LRS. Default value is Premium_LRS.'
171-
'Must set iops and throughput if using PremiumV2_LRS.'
170+
help='Storage type for the server. Allowed values are Premium_LRS and PremiumV2_LRS. '
171+
'Default value is Premium_LRS. Must set --iops and --throughput if using PremiumV2_LRS.'
172172
)
173173

174174
storage_type_replica_arg_type = CLIArgumentType(
175175
arg_type=get_enum_type(['PremiumV2_LRS']),
176176
options_list=['--storage-type'],
177-
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.'
177+
help='Storage type for the read replica. Allowed value is PremiumV2_LRS. '
178+
'Default is for the read replica to match storage type of the primary server.'
178179
)
179180

180181
storage_type_restore_arg_type = CLIArgumentType(
181182
arg_type=get_enum_type(['PremiumV2_LRS']),
182183
options_list=['--storage-type'],
183-
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.'
184+
help='Storage type for the new server. Allowed value is PremiumV2_LRS. '
185+
'Default is for the new server to match storage type of the source server.'
184186
)
185187

186188
performance_tier_arg_type = CLIArgumentType(
@@ -196,30 +198,17 @@ def _flexible_server_params(command_group):
196198

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

206-
vnet_address_prefix_arg_type = CLIArgumentType(
207-
options_list=['--address-prefixes'],
208-
help='The IP address prefix to use when creating a new virtual network in CIDR format. '
209-
'Default value is 10.0.0.0/16.'
210-
)
211-
212208
subnet_arg_type = CLIArgumentType(
213209
options_list=['--subnet'],
214-
help='Name or resource ID of a new or existing subnet. '
215-
'If you want to use a subnet from different resource group or subscription, please provide resource ID instead of name. '
216-
'Please note that the subnet will be delegated to flexibleServers. '
217-
'After delegation, this subnet cannot be used for any other type of Azure resources.'
218-
)
219-
220-
subnet_address_prefix_arg_type = CLIArgumentType(
221-
options_list=['--subnet-prefixes'],
222-
help='The subnet IP address prefix to use when creating a new subnet in CIDR format. Default value is 10.0.0.0/24.'
210+
help='Name or identifier of an existing subnet. '
211+
'If you want to use a subnet from a different resource group or subscription, please provide its resource identifier instead of name.'
223212
)
224213

225214
zone_arg_type = CLIArgumentType(
@@ -275,23 +264,22 @@ def _flexible_server_params(command_group):
275264

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

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

292280
source_server_arg_type = CLIArgumentType(
293281
options_list=['--source-server'],
294-
help='The name or resource ID of the source server to restore from.'
282+
help='The name or resource identifier of the source server to restore from.'
295283
)
296284

297285
geo_redundant_backup_arg_type = CLIArgumentType(
@@ -302,30 +290,30 @@ def _flexible_server_params(command_group):
302290

303291
identity_arg_type = CLIArgumentType(
304292
options_list=['--identity'],
305-
help='The name or resource ID of the user assigned identity for data encryption.',
293+
help='The name or resource identifier of the user assigned identity for data encryption.',
306294
validator=validate_byok_identity
307295
)
308296

309297
backup_identity_arg_type = CLIArgumentType(
310298
options_list=['--backup-identity'],
311-
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.',
299+
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.',
312300
validator=validate_byok_identity
313301
)
314302

315303
key_arg_type = CLIArgumentType(
316304
options_list=['--key'],
317-
help='The resource ID of the primary keyvault key for data encryption.'
305+
help='The resource identifier of the primary keyvault key for data encryption.'
318306
)
319307

320308
backup_key_arg_type = CLIArgumentType(
321309
options_list=['--backup-key'],
322-
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.'
310+
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.'
323311
)
324312

325313
identities_arg_type = CLIArgumentType(
326314
options_list=['--identity', '-n'],
327315
nargs='+',
328-
help='Space-separated names or ID\'s of identities.',
316+
help='Space-separated names or identifiers of identities.',
329317
validator=validate_identities
330318
)
331319

@@ -390,7 +378,7 @@ def _flexible_server_params(command_group):
390378
c.argument('version', arg_type=version_arg_type)
391379
c.argument('backup_retention', default=7, arg_type=pg_backup_retention_arg_type)
392380
c.argument('microsoft_entra_auth', default='Disabled', arg_type=microsoft_entra_auth_arg_type)
393-
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
381+
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique identifier of the Microsoft Entra administrator.')
394382
c.argument('admin_name', options_list=['--admin-display-name', '-m'], help='Display name of the Microsoft Entra administrator user or group.')
395383
c.argument('admin_type', options_list=['--admin-type', '-t'],
396384
arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Microsoft Entra administrator.')
@@ -415,9 +403,7 @@ def _flexible_server_params(command_group):
415403
c.argument('high_availability', arg_type=high_availability_arg_type, default="Disabled")
416404
c.argument('public_access', arg_type=public_access_create_arg_type)
417405
c.argument('vnet', arg_type=vnet_arg_type)
418-
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
419406
c.argument('subnet', arg_type=subnet_arg_type)
420-
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
421407
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
422408
c.argument('zone', zone_arg_type)
423409
c.argument('tags', tags_type)
@@ -435,9 +421,7 @@ def _flexible_server_params(command_group):
435421
c.argument('restore_point_in_time', arg_type=restore_point_in_time_arg_type)
436422
c.argument('source_server', arg_type=source_server_arg_type)
437423
c.argument('vnet', arg_type=vnet_arg_type)
438-
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
439424
c.argument('subnet', arg_type=subnet_arg_type)
440-
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
441425
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
442426
c.argument('zone', arg_type=zone_arg_type)
443427
c.argument('yes', arg_type=yes_arg_type)
@@ -453,9 +437,7 @@ def _flexible_server_params(command_group):
453437
c.argument('sku_name', arg_type=sku_name_arg_type)
454438
c.argument('source_server', arg_type=source_server_arg_type)
455439
c.argument('vnet', arg_type=vnet_arg_type)
456-
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
457440
c.argument('subnet', arg_type=subnet_arg_type)
458-
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
459441
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
460442
c.argument('zone', arg_type=zone_arg_type)
461443
c.argument('yes', arg_type=yes_arg_type)
@@ -471,9 +453,7 @@ def _flexible_server_params(command_group):
471453
c.argument('sku_name', arg_type=sku_name_arg_type)
472454
c.argument('source_server', arg_type=source_server_arg_type)
473455
c.argument('vnet', arg_type=vnet_arg_type)
474-
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
475456
c.argument('subnet', arg_type=subnet_arg_type)
476-
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
477457
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
478458
c.argument('zone', arg_type=zone_arg_type)
479459
c.argument('yes', arg_type=yes_arg_type)
@@ -614,8 +594,6 @@ def _flexible_server_params(command_group):
614594
c.argument('vnet', arg_type=vnet_arg_type)
615595
c.argument('subnet', arg_type=subnet_arg_type)
616596
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
617-
c.argument('vnet_address_prefix', arg_type=vnet_address_prefix_arg_type)
618-
c.argument('subnet_address_prefix', arg_type=subnet_address_prefix_arg_type)
619597
c.argument('byok_key', arg_type=key_arg_type)
620598
c.argument('byok_identity', arg_type=identity_arg_type)
621599
c.argument('tier', arg_type=tier_arg_type)
@@ -665,7 +643,7 @@ def _flexible_server_params(command_group):
665643
c.argument('identities', arg_type=identities_arg_type)
666644

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

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

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

693671
with self.argument_context('{} flexible-server microsoft-entra-admin create'.format(command_group)) as c:
694672
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Microsoft Entra administrator user or group.')
695673
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.')
696-
c.argument('identity', help='Name or ID of identity used for Microsoft Entra Authentication.', validator=validate_identity)
674+
c.argument('identity', help='Name or identifier of identity used for Microsoft Entra Authentication.', validator=validate_identity)
697675

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

0 commit comments

Comments
 (0)