Skip to content

Commit 3f2a250

Browse files
authored
{RDBMS} az postgres flexible-server create, az postgres flexible-server update, az postgres flexible-server ad-admin: Add upcoming breaking change announcements (#31112)
* add to ignore * Fix bug when updating cmk geo * Revert "add to ignore" This reverts commit ee1192c. * Updates to not create password if pasword is disabled * Revert "Updates to not create password if pasword is disabled" This reverts commit 3b1d20b. * init * Lint fixes and tests * Trigger build * PR changes * Include stop replica in announcment * Correct announcement text * Create breaking change file
1 parent 7fe5cd8 commit 3f2a250

9 files changed

+18225
-24
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from azure.cli.core.breaking_change import register_command_group_deprecate, register_default_value_breaking_change, \
7+
register_argument_deprecate, register_other_breaking_change, register_logic_breaking_change, \
8+
register_command_deprecate
9+
10+
11+
register_logic_breaking_change('postgres flexible-server create', 'Update default value of "--sku-name"',
12+
detail='The default value will be changed from "Standard_D2s_v3" to a '
13+
'supported sku based on regional capabilities.')
14+
register_default_value_breaking_change('postgres flexible-server create', '--version', '16', '17')
15+
register_default_value_breaking_change('postgres flexible-server create', '--create-default-database', 'Enabled',
16+
'Disabled')
17+
register_argument_deprecate('postgres flexible-server create', '--active-directory-auth', '--microsoft-entra-auth')
18+
register_argument_deprecate('postgres flexible-server update', '--active-directory-auth', '--microsoft-entra-auth')
19+
register_command_group_deprecate('postgres flexible-server ad-admin', redirect='microsoft-entra-admin')
20+
register_command_deprecate('postgres flexible-server replica stop-replication',
21+
redirect='postgres flexible-server replica promote', hide=True)
22+
register_other_breaking_change('postgres flexible-server update',
23+
message='User confirmation will be needed for compute and storage updates '
24+
'that trigger a restart of the server.')

src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@
140140
# create flexible server with aad auth and password auth enabled
141141
142142
az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
143-
--active-directory-auth Enabled
143+
--microsoft-entra-auth Enabled
144144
- name: >
145145
Create a PostgreSQL flexible server with Microsoft Entra auth only and primary administrator specified.
146146
text: >
147147
# create flexible server with aad only auth and password auth disabled with primary administrator specified
148148
149149
az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
150-
--active-directory-auth Enabled --password-auth Disabled \\
150+
--microsoft-entra-auth Enabled --password-auth Disabled \\
151151
--admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name john@contoso.com --admin-type User
152152
- name: >
153153
Create a PostgreSQL flexible server with public access, geo-redundant backup enabled and add the range of IP address to have access to this server.
@@ -258,7 +258,7 @@
258258
- name: Reset password
259259
text: az postgres flexible-server update --resource-group testGroup --name testserver -p password123
260260
- name: Update a flexible server to enable Microsoft Entra auth for password auth enabled server
261-
text: az postgres flexible-server update --resource-group testGroup --name testserver --active-directory-auth Enabled
261+
text: az postgres flexible-server update --resource-group testGroup --name testserver --microsoft-entra-auth Enabled
262262
- name: Change key/identity for data encryption. Data encryption cannot be enabled post server creation, this will only update the key/identity.
263263
text: >
264264
# get key identifier of the existing key
@@ -1005,6 +1005,53 @@
10051005
text: az postgres flexible-server ad-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --deleted
10061006
"""
10071007

1008+
helps['postgres flexible-server microsoft-entra-admin'] = """
1009+
type: group
1010+
short-summary: Manage server Microsoft Entra administrators.
1011+
"""
1012+
1013+
helps['postgres flexible-server microsoft-entra-admin create'] = """
1014+
type: command
1015+
short-summary: Create a Microsoft Entra administrator.
1016+
examples:
1017+
- name: Create Microsoft Entra administrator with user 'john@contoso.com', administrator ID '00000000-0000-0000-0000-000000000000' and type User.
1018+
text: az postgres flexible-server microsoft-entra-admin create -g testgroup -s testsvr -u john@contoso.com -i 00000000-0000-0000-0000-000000000000 -t User
1019+
"""
1020+
1021+
helps['postgres flexible-server microsoft-entra-admin delete'] = """
1022+
type: command
1023+
short-summary: Delete a Microsoft Entra administrator.
1024+
examples:
1025+
- name: Delete Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
1026+
text: az postgres flexible-server microsoft-entra-admin delete -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
1027+
"""
1028+
1029+
helps['postgres flexible-server microsoft-entra-admin list'] = """
1030+
type: command
1031+
short-summary: List all Microsoft Entra administrators.
1032+
examples:
1033+
- name: List Microsoft Entra administrators.
1034+
text: az postgres flexible-server microsoft-entra-admin list -g testgroup -s testsvr
1035+
"""
1036+
1037+
helps['postgres flexible-server microsoft-entra-admin show'] = """
1038+
type: command
1039+
short-summary: Get a Microsoft Entra administrator.
1040+
examples:
1041+
- name: Get Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
1042+
text: az postgres flexible-server microsoft-entra-admin show -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
1043+
"""
1044+
1045+
helps['postgres flexible-server microsoft-entra-admin wait'] = """
1046+
type: command
1047+
short-summary: Wait for a Microsoft Entra administrator to satisfy certain conditions.
1048+
examples:
1049+
- name: Wait until a Microsoft Entra administrator exists.
1050+
text: az postgres flexible-server microsoft-entra-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --exists
1051+
- name: Wait for a Microsoft Entra administrator to be deleted.
1052+
text: az postgres flexible-server microsoft-entra-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --deleted
1053+
"""
1054+
10081055
helps['postgres flexible-server advanced-threat-protection-setting'] = """
10091056
type: group
10101057
short-summary: Manage advanced threat protection setting for a PostgreSQL flexible server.

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ def _flexible_server_params(command_group):
532532
help='Whether Microsoft Entra authentication is enabled.'
533533
)
534534

535+
microsoft_entra_auth_arg_type = CLIArgumentType(
536+
options_list=['--microsoft-entra-auth'],
537+
arg_type=get_enum_type(['Enabled', 'Disabled']),
538+
help='Whether Microsoft Entra authentication is enabled.'
539+
)
540+
535541
password_auth_arg_type = CLIArgumentType(
536542
options_list=['--password-auth'],
537543
arg_type=get_enum_type(['Enabled', 'Disabled']),
@@ -594,6 +600,7 @@ def _flexible_server_params(command_group):
594600
c.argument('version', default='16', arg_type=version_arg_type)
595601
c.argument('backup_retention', default=7, arg_type=pg_backup_retention_arg_type)
596602
c.argument('active_directory_auth', default='Disabled', arg_type=active_directory_auth_arg_type)
603+
c.argument('microsoft_entra_auth', default='Disabled', arg_type=microsoft_entra_auth_arg_type)
597604
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
598605
c.argument('admin_name', options_list=['--admin-display-name', '-m'], help='Display name of the Microsoft Entra administrator user or group.')
599606
c.argument('admin_type', options_list=['--admin-type', '-t'],
@@ -747,6 +754,7 @@ def _flexible_server_params(command_group):
747754
c.argument('throughput', default=None, arg_type=throughput_arg_type)
748755
c.argument('backup_retention', arg_type=pg_backup_retention_arg_type)
749756
c.argument('active_directory_auth', arg_type=active_directory_auth_arg_type)
757+
c.argument('microsoft_entra_auth', arg_type=microsoft_entra_auth_arg_type)
750758
c.argument('password_auth', arg_type=password_auth_arg_type)
751759
c.argument('private_dns_zone_arguments', private_dns_zone_arguments_arg_type)
752760
c.argument('cluster_size', default=None, arg_type=update_node_count_arg_type)
@@ -975,7 +983,7 @@ def _flexible_server_params(command_group):
975983
c.argument('database_names', options_list=['--database-names', '-d'], nargs='+',
976984
help='Space-separated list of the database names to be mirrored. Required if --mirroring is enabled.')
977985

978-
# ad-admin
986+
# ad-admin - Rename and deprecate group
979987
with self.argument_context('{} flexible-server ad-admin'.format(command_group)) as c:
980988
c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
981989

@@ -988,6 +996,19 @@ def _flexible_server_params(command_group):
988996
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.')
989997
c.argument('identity', help='Name or ID of identity used for AAD Authentication.', validator=validate_identity)
990998

999+
# microsoft-entra-admin
1000+
with self.argument_context('{} flexible-server microsoft-entra-admin'.format(command_group)) as c:
1001+
c.argument('server_name', id_part=None, options_list=['--server-name', '-s'], arg_type=server_name_arg_type)
1002+
1003+
for scope in ['create', 'show', 'delete', 'wait']:
1004+
with self.argument_context('{} flexible-server microsoft-entra-admin {}'.format(command_group, scope)) as c:
1005+
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
1006+
1007+
with self.argument_context('{} flexible-server microsoft-entra-admin create'.format(command_group)) as c:
1008+
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Microsoft Entra administrator user or group.')
1009+
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.')
1010+
c.argument('identity', help='Name or ID of identity used for Microsoft Entra Authentication.', validator=validate_identity)
1011+
9911012
# server advanced threat protection settings
9921013
for scope in ['update', 'show']:
9931014
argument_context_string = '{} flexible-server advanced-threat-protection-setting {}'.format(command_group, scope)

src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_commands.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def load_flexibleserver_command_table(self, _):
238238
custom_command_type=flexible_servers_custom_postgres,
239239
client_factory=cf_postgres_flexible_servers) as g:
240240
g.custom_command('create', 'flexible_replica_create', supports_no_wait=True)
241-
g.custom_command('stop-replication', 'flexible_replica_stop', confirmation=True, deprecate_info=g.deprecate(redirect='postgres flexible-server replica promote', hide=True))
241+
g.custom_command('stop-replication', 'flexible_replica_stop', confirmation=True)
242242
g.custom_command('promote', 'flexible_replica_promote', confirmation=True)
243243

244244
with self.command_group('postgres flexible-server identity', postgres_flexible_servers_sdk,
@@ -259,6 +259,15 @@ def load_flexibleserver_command_table(self, _):
259259
g.custom_show_command('show', 'flexible_server_ad_admin_show')
260260
g.custom_wait_command('wait', 'flexible_server_ad_admin_show')
261261

262+
with self.command_group('postgres flexible-server microsoft-entra-admin', postgres_flexible_adadmin_sdk,
263+
custom_command_type=flexible_servers_custom_postgres,
264+
client_factory=cf_postgres_flexible_adadmin) as g:
265+
g.custom_command('create', 'flexible_server_ad_admin_set', supports_no_wait=True)
266+
g.custom_command('delete', 'flexible_server_ad_admin_delete', supports_no_wait=True, confirmation=True)
267+
g.custom_command('list', 'flexible_server_ad_admin_list')
268+
g.custom_show_command('show', 'flexible_server_ad_admin_show')
269+
g.custom_wait_command('wait', 'flexible_server_ad_admin_show')
270+
262271
with self.command_group('postgres flexible-server advanced-threat-protection-setting', postgres_flexible_server_threat_protection_settings_sdk,
263272
custom_command_type=flexible_servers_custom_postgres,
264273
client_factory=cf_postgres_flexible_server_threat_protection_settings) as g:

src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def flexible_server_create(cmd, client,
5858
resource_group_name=None, server_name=None,
5959
location=None, backup_retention=None,
6060
sku_name=None, tier=None,
61-
storage_gb=None, version=None, active_directory_auth=None,
61+
storage_gb=None, version=None, active_directory_auth=None, microsoft_entra_auth=None,
6262
admin_name=None, admin_id=None, admin_type=None,
6363
password_auth=None, administrator_login=None, administrator_login_password=None,
6464
tags=None, database_name=None,
@@ -106,7 +106,7 @@ def flexible_server_create(cmd, client,
106106
backup_byok_key=backup_byok_key,
107107
performance_tier=performance_tier,
108108
create_cluster=create_cluster,
109-
password_auth=password_auth, active_directory_auth=active_directory_auth,
109+
password_auth=password_auth, active_directory_auth=active_directory_auth, microsoft_entra_auth=microsoft_entra_auth,
110110
admin_name=admin_name, admin_id=admin_id, admin_type=admin_type,)
111111

112112
cluster = None
@@ -140,7 +140,8 @@ def flexible_server_create(cmd, client,
140140
standby_availability_zone=standby_availability_zone)
141141

142142
is_password_auth_enabled = bool(password_auth is not None and password_auth.lower() == 'enabled')
143-
is_microsoft_entra_auth_enabled = bool(active_directory_auth is not None and active_directory_auth.lower() == 'enabled')
143+
is_microsoft_entra_auth_enabled = bool(active_directory_auth is not None and active_directory_auth.lower() == 'enabled') or \
144+
bool(microsoft_entra_auth is not None and microsoft_entra_auth.lower() == 'enabled')
144145
if is_password_auth_enabled:
145146
administrator_login_password = generate_password(administrator_login_password)
146147

@@ -150,7 +151,7 @@ def flexible_server_create(cmd, client,
150151
backup_byok_identity=backup_byok_identity,
151152
backup_byok_key=backup_byok_key)
152153

153-
auth_config = postgresql_flexibleservers.models.AuthConfig(active_directory_auth=active_directory_auth,
154+
auth_config = postgresql_flexibleservers.models.AuthConfig(active_directory_auth='Enabled' if is_microsoft_entra_auth_enabled else 'Disabled',
154155
password_auth=password_auth)
155156

156157
# Create postgresql
@@ -191,7 +192,7 @@ def flexible_server_create(cmd, client,
191192

192193
user = server_result.administrator_login if is_password_auth_enabled else '<user>'
193194
password = administrator_login_password if is_password_auth_enabled else '<password>'
194-
admin = admin_name if admin_name else '<admin>'
195+
admin = quote(admin_name) if admin_name else '<admin>'
195196
server_id = server_result.id
196197
loc = server_result.location
197198
version = server_result.version
@@ -310,7 +311,7 @@ def flexible_server_update_custom_func(cmd, client, instance,
310311
maintenance_window=None,
311312
byok_identity=None, byok_key=None,
312313
backup_byok_identity=None, backup_byok_key=None,
313-
active_directory_auth=None, password_auth=None,
314+
active_directory_auth=None, microsoft_entra_auth=None, password_auth=None,
314315
private_dns_zone_arguments=None,
315316
public_access=None,
316317
tags=None,
@@ -424,8 +425,8 @@ def flexible_server_update_custom_func(cmd, client, instance,
424425

425426
auth_config = instance.auth_config
426427
administrator_login = instance.administrator_login if instance.administrator_login else None
427-
if active_directory_auth:
428-
auth_config.active_directory_auth = active_directory_auth
428+
if active_directory_auth or microsoft_entra_auth:
429+
auth_config.active_directory_auth = active_directory_auth if active_directory_auth else microsoft_entra_auth
429430
if password_auth:
430431
administrator_login, administrator_login_password = _update_login(server_name, resource_group_name, auth_config,
431432
password_auth, administrator_login, administrator_login_password)
@@ -1792,7 +1793,7 @@ def _create_postgresql_connection_string(host, user, password, database):
17921793

17931794
def _create_microsoft_entra_connection_string(host, database, admin='<admin>'):
17941795
connection_kwargs = {
1795-
'user': quote(admin),
1796+
'user': admin,
17961797
'host': host,
17971798
'database': database,
17981799
}

0 commit comments

Comments
 (0)