Skip to content

Commit a6798ae

Browse files
authored
[RDBMS] az postgres flexible-server create: Bug fix, generating password when password auth is disabled. Support adding admin during create if Microsoft Entra is enabled. (#30999)
* 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 * Add admin during create * Update text * fixes * fix * PR comments * PR comments * lint fix * Revert "Updates to not create password if pasword is disabled" This reverts commit 3b1d20b. * PR comments * add to ignore * Revert "add to ignore" This reverts commit ee1192c. * Updates to not create password if pasword is disabled * Add admin during create * Update text * fixes * fix * PR comments * PR comments * lint fix * Revert "Updates to not create password if pasword is disabled" This reverts commit 3b1d20b. * PR comments * Lint fixes * merge fix
1 parent ce6b627 commit a6798ae

File tree

4 files changed

+112
-50
lines changed

4 files changed

+112
-50
lines changed

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,20 @@
135135
az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
136136
--key $keyIdentifier --identity testIdentity
137137
- name: >
138-
Create a PostgreSQL flexible server with active directory auth as well as password auth.
138+
Create a PostgreSQL flexible server with Microsoft Entra auth as well as password auth.
139139
text: >
140140
# create flexible server with aad auth and password auth enabled
141141
142142
az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
143143
--active-directory-auth Enabled
144144
- name: >
145-
Create a PostgreSQL flexible server with active directory auth only.
145+
Create a PostgreSQL flexible server with Microsoft Entra auth only and primary administrator specified.
146146
text: >
147-
# create flexible server with aad only auth and password auth disabled
147+
# 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+
--active-directory-auth Enabled --password-auth Disabled \\
151+
--admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name [email protected] --admin-type User
151152
- name: >
152153
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.
153154
The --public-access parameter can be 'All', 'None', <startIpAddress>, or <startIpAddress>-<endIpAddress>
@@ -256,7 +257,7 @@
256257
text: az postgres flexible-server update --resource-group testGroup --name testserver --tags "k1=v1" "k2=v2"
257258
- name: Reset password
258259
text: az postgres flexible-server update --resource-group testGroup --name testserver -p password123
259-
- name: Update a flexible server to enable active directory auth for password auth enabled server
260+
- name: Update a flexible server to enable Microsoft Entra auth for password auth enabled server
260261
text: az postgres flexible-server update --resource-group testGroup --name testserver --active-directory-auth Enabled
261262
- name: Change key/identity for data encryption. Data encryption cannot be enabled post server creation, this will only update the key/identity.
262263
text: >
@@ -959,48 +960,48 @@
959960

960961
helps['postgres flexible-server ad-admin'] = """
961962
type: group
962-
short-summary: Manage server Active Directory administrators.
963+
short-summary: Manage server Microsoft Entra administrators.
963964
"""
964965

965966
helps['postgres flexible-server ad-admin create'] = """
966967
type: command
967-
short-summary: Create an Active Directory administrator.
968+
short-summary: Create a Microsoft Entra administrator.
968969
examples:
969-
- name: Create Active Directory administrator with user '[email protected]', administrator ID '00000000-0000-0000-0000-000000000000' and type User.
970+
- name: Create Microsoft Entra administrator with user '[email protected]', administrator ID '00000000-0000-0000-0000-000000000000' and type User.
970971
text: az postgres flexible-server ad-admin create -g testgroup -s testsvr -u [email protected] -i 00000000-0000-0000-0000-000000000000 -t User
971972
"""
972973

973974
helps['postgres flexible-server ad-admin delete'] = """
974975
type: command
975-
short-summary: Delete an Active Directory administrator.
976+
short-summary: Delete a Microsoft Entra administrator.
976977
examples:
977-
- name: Delete Active Directory administrator with ID '00000000-0000-0000-0000-000000000000'.
978+
- name: Delete Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
978979
text: az postgres flexible-server ad-admin delete -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
979980
"""
980981

981982
helps['postgres flexible-server ad-admin list'] = """
982983
type: command
983-
short-summary: List all Active Directory administrators.
984+
short-summary: List all Microsoft Entra administrators.
984985
examples:
985-
- name: List Active Directory administrators.
986+
- name: List Microsoft Entra administrators.
986987
text: az postgres flexible-server ad-admin list -g testgroup -s testsvr
987988
"""
988989

989990
helps['postgres flexible-server ad-admin show'] = """
990991
type: command
991-
short-summary: Get an Active Directory administrator.
992+
short-summary: Get a Microsoft Entra administrator.
992993
examples:
993-
- name: Get Active Directory administrator with ID '00000000-0000-0000-0000-000000000000'.
994+
- name: Get Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
994995
text: az postgres flexible-server ad-admin show -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
995996
"""
996997

997998
helps['postgres flexible-server ad-admin wait'] = """
998999
type: command
999-
short-summary: Wait for an Active Directory administrator to satisfy certain conditions.
1000+
short-summary: Wait for a Microsoft Entra administrator to satisfy certain conditions.
10001001
examples:
1001-
- name: Wait until an Active Directory administrator exists.
1002+
- name: Wait until a Microsoft Entra administrator exists.
10021003
text: az postgres flexible-server ad-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --exists
1003-
- name: Wait for an Active Directory administrator to be deleted.
1004+
- name: Wait for a Microsoft Entra administrator to be deleted.
10041005
text: az postgres flexible-server ad-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --deleted
10051006
"""
10061007

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
7070
c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')
7171
c.argument('auto_scale_iops', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-scale-iops'], help='Enable or disable autoscale of iops. Default value is Disabled.')
7272
c.argument('infrastructure_encryption', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--infrastructure-encryption', '-i'], help='Add an optional second layer of encryption for data using new encryption algorithm. Default value is Disabled.')
73-
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')
73+
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Microsoft Entra Identity for this server for use with key management services like Azure KeyVault.')
7474
c.argument('tags', tags_type)
7575

7676
if command_group == 'mariadb':
@@ -90,7 +90,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
9090
c.argument('auto_grow', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-grow'], help='Enable or disable autogrow of the storage. Default value is Enabled.')
9191
c.argument('auto_scale_iops', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--auto-scale-iops'], help='Enable or disable autogrow of the storage. Default value is Disabled.')
9292
c.argument('infrastructure_encryption', arg_type=get_enum_type(['Enabled', 'Disabled']), options_list=['--infrastructure-encryption', '-i'], help='Add an optional second layer of encryption for data using new encryption algorithm. Default value is Disabled.')
93-
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')
93+
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Microsoft Entra Identity for this server for use with key management services like Azure KeyVault.')
9494

9595
c.argument('location', arg_type=get_location_type(self.cli_ctx))
9696
if command_group == 'postgres':
@@ -102,7 +102,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
102102
with self.argument_context('{} server update'.format(command_group)) as c:
103103
c.ignore('family', 'capacity', 'tier')
104104
c.argument('sku_name', options_list=['--sku-name'], help='The name of the sku. Follows the convention {pricing tier}_{compute generation}_{vCores} in shorthand. Examples: B_Gen5_1, GP_Gen5_4, MO_Gen5_16.')
105-
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Azure Active Directory Identity for this server for use with key management services like Azure KeyVault.')
105+
c.argument('assign_identity', options_list=['--assign-identity'], help='Generate and assign an Microsoft Entra Identity for this server for use with key management services like Azure KeyVault.')
106106

107107
with self.argument_context('{} server restore'. format(command_group)) as c:
108108
c.argument('server_name', options_list=['--name', '-n'], arg_type=overriding_none_arg_type)
@@ -211,8 +211,8 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
211211

212212
with self.argument_context('{} server ad-admin'.format(command_group)) as c:
213213
c.argument('server_name', options_list=['--server-name', '-s'])
214-
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Azure AD administrator user or group.')
215-
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Azure AD administrator.')
214+
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Microsoft Entra administrator user or group.')
215+
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
216216

217217
if command_group == 'mysql':
218218
with self.argument_context('{} server upgrade'.format(command_group)) as c:
@@ -529,7 +529,7 @@ def _flexible_server_params(command_group):
529529
active_directory_auth_arg_type = CLIArgumentType(
530530
options_list=['--active-directory-auth'],
531531
arg_type=get_enum_type(['Enabled', 'Disabled']),
532-
help='Whether Azure Active Directory authentication is enabled.'
532+
help='Whether Microsoft Entra authentication is enabled.'
533533
)
534534

535535
password_auth_arg_type = CLIArgumentType(
@@ -594,6 +594,10 @@ def _flexible_server_params(command_group):
594594
c.argument('version', default='16', arg_type=version_arg_type)
595595
c.argument('backup_retention', default=7, arg_type=pg_backup_retention_arg_type)
596596
c.argument('active_directory_auth', default='Disabled', arg_type=active_directory_auth_arg_type)
597+
c.argument('admin_id', options_list=['--admin-object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
598+
c.argument('admin_name', options_list=['--admin-display-name', '-m'], help='Display name of the Microsoft Entra administrator user or group.')
599+
c.argument('admin_type', options_list=['--admin-type', '-t'],
600+
arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Microsoft Entra administrator.')
597601
c.argument('password_auth', default='Enabled', arg_type=password_auth_arg_type)
598602
c.argument('auto_grow', default='Disabled', arg_type=auto_grow_arg_type)
599603
c.argument('storage_type', default=None, arg_type=storage_type_arg_type)
@@ -977,11 +981,11 @@ def _flexible_server_params(command_group):
977981

978982
for scope in ['create', 'show', 'delete', 'wait']:
979983
with self.argument_context('{} flexible-server ad-admin {}'.format(command_group, scope)) as c:
980-
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Azure AD administrator.')
984+
c.argument('sid', options_list=['--object-id', '-i'], help='The unique ID of the Microsoft Entra administrator.')
981985

982986
with self.argument_context('{} flexible-server ad-admin create'.format(command_group)) as c:
983-
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Azure AD administrator user or group.')
984-
c.argument('principal_type', options_list=['--type', '-t'], default='User', arg_type=get_enum_type(['User', 'Group', 'ServicePrincipal', 'Unknown']), help='Type of the Azure AD administrator.')
987+
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Microsoft Entra administrator user or group.')
988+
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.')
985989
c.argument('identity', help='Name or ID of identity used for AAD Authentication.', validator=validate_identity)
986990

987991
# server advanced threat protection settings

0 commit comments

Comments
 (0)