Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
35 changes: 18 additions & 17 deletions src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,20 @@
az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
--key $keyIdentifier --identity testIdentity
- name: >
Create a PostgreSQL flexible server with active directory auth as well as password auth.
Create a PostgreSQL flexible server with Microsoft Entra auth as well as password auth.
text: >
# create flexible server with aad auth and password auth enabled

az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
--active-directory-auth Enabled
- name: >
Create a PostgreSQL flexible server with active directory auth only.
Create a PostgreSQL flexible server with Microsoft Entra auth only and primary administrator specified.
text: >
# create flexible server with aad only auth and password auth disabled
# create flexible server with aad only auth and password auth disabled with primary administrator specified

az postgres flexible-server create -g testGroup -n testServer --location testLocation \\
--active-directory-auth Enabled --password-auth Disabled
--active-directory-auth Enabled --password-auth Disabled \\
--admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name john@contoso.com --admin-type User
- name: >
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.
The --public-access parameter can be 'All', 'None', <startIpAddress>, or <startIpAddress>-<endIpAddress>
Expand Down Expand Up @@ -256,7 +257,7 @@
text: az postgres flexible-server update --resource-group testGroup --name testserver --tags "k1=v1" "k2=v2"
- name: Reset password
text: az postgres flexible-server update --resource-group testGroup --name testserver -p password123
- name: Update a flexible server to enable active directory auth for password auth enabled server
- name: Update a flexible server to enable Microsoft Entra auth for password auth enabled server
text: az postgres flexible-server update --resource-group testGroup --name testserver --active-directory-auth Enabled
- name: Change key/identity for data encryption. Data encryption cannot be enabled post server creation, this will only update the key/identity.
text: >
Expand Down Expand Up @@ -959,48 +960,48 @@

helps['postgres flexible-server ad-admin'] = """
type: group
short-summary: Manage server Active Directory administrators.
short-summary: Manage server Microsoft Entra administrators.
"""

helps['postgres flexible-server ad-admin create'] = """
type: command
short-summary: Create an Active Directory administrator.
short-summary: Create a Microsoft Entra administrator.
examples:
- name: Create Active Directory administrator with user 'john@contoso.com', administrator ID '00000000-0000-0000-0000-000000000000' and type User.
- name: Create Microsoft Entra administrator with user 'john@contoso.com', administrator ID '00000000-0000-0000-0000-000000000000' and type User.
text: az postgres flexible-server ad-admin create -g testgroup -s testsvr -u john@contoso.com -i 00000000-0000-0000-0000-000000000000 -t User
"""

helps['postgres flexible-server ad-admin delete'] = """
type: command
short-summary: Delete an Active Directory administrator.
short-summary: Delete a Microsoft Entra administrator.
examples:
- name: Delete Active Directory administrator with ID '00000000-0000-0000-0000-000000000000'.
- name: Delete Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
text: az postgres flexible-server ad-admin delete -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
"""

helps['postgres flexible-server ad-admin list'] = """
type: command
short-summary: List all Active Directory administrators.
short-summary: List all Microsoft Entra administrators.
examples:
- name: List Active Directory administrators.
- name: List Microsoft Entra administrators.
text: az postgres flexible-server ad-admin list -g testgroup -s testsvr
"""

helps['postgres flexible-server ad-admin show'] = """
type: command
short-summary: Get an Active Directory administrator.
short-summary: Get a Microsoft Entra administrator.
examples:
- name: Get Active Directory administrator with ID '00000000-0000-0000-0000-000000000000'.
- name: Get Microsoft Entra administrator with ID '00000000-0000-0000-0000-000000000000'.
text: az postgres flexible-server ad-admin show -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000
"""

helps['postgres flexible-server ad-admin wait'] = """
type: command
short-summary: Wait for an Active Directory administrator to satisfy certain conditions.
short-summary: Wait for a Microsoft Entra administrator to satisfy certain conditions.
examples:
- name: Wait until an Active Directory administrator exists.
- name: Wait until a Microsoft Entra administrator exists.
text: az postgres flexible-server ad-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --exists
- name: Wait for an Active Directory administrator to be deleted.
- name: Wait for a Microsoft Entra administrator to be deleted.
text: az postgres flexible-server ad-admin wait -g testgroup -s testsvr -i 00000000-0000-0000-0000-000000000000 --deleted
"""

Expand Down
22 changes: 13 additions & 9 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
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.')
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.')
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.')
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.')
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.')
c.argument('tags', tags_type)

if command_group == 'mariadb':
Expand All @@ -90,7 +90,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
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.')
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.')
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.')
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.')
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.')

c.argument('location', arg_type=get_location_type(self.cli_ctx))
if command_group == 'postgres':
Expand All @@ -102,7 +102,7 @@ def _complex_params(command_group): # pylint: disable=too-many-statements
with self.argument_context('{} server update'.format(command_group)) as c:
c.ignore('family', 'capacity', 'tier')
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.')
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.')
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.')

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

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

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

password_auth_arg_type = CLIArgumentType(
Expand Down Expand Up @@ -594,6 +594,10 @@ def _flexible_server_params(command_group):
c.argument('version', default='16', arg_type=version_arg_type)
c.argument('backup_retention', default=7, arg_type=pg_backup_retention_arg_type)
c.argument('active_directory_auth', default='Disabled', arg_type=active_directory_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_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.')
c.argument('password_auth', default='Enabled', arg_type=password_auth_arg_type)
c.argument('auto_grow', default='Disabled', arg_type=auto_grow_arg_type)
c.argument('storage_type', default=None, arg_type=storage_type_arg_type)
Expand Down Expand Up @@ -977,11 +981,11 @@ def _flexible_server_params(command_group):

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

with self.argument_context('{} flexible-server ad-admin create'.format(command_group)) as c:
c.argument('login', options_list=['--display-name', '-u'], help='Display name of the Azure AD 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 Azure AD administrator.')
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 AAD Authentication.', validator=validate_identity)

# server advanced threat protection settings
Expand Down
Loading