-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
base: dev
Are you sure you want to change the base?
Conversation
Add to ignore
This reverts commit ee1192c.
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
Validation for Breaking Change Starting...
Thanks for your contribution! |
Thank you for your contribution! We will review the pull request and get back to you soon. |
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py
Outdated
Show resolved
Hide resolved
@evelyn-ys can you please trigger checks |
@@ -132,7 +136,10 @@ def flexible_server_create(cmd, client, | |||
high_availability = postgresql_flexibleservers.models.HighAvailability(mode=high_availability, | |||
standby_availability_zone=standby_availability_zone) | |||
|
|||
administrator_login_password = generate_password(administrator_login_password) | |||
is_password_auth_enabled = bool(password_auth is not None and password_auth.lower() == 'enabled') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should validate that either or both password-based and Microsoft Entra authentication are enabled, to avoid getting the following error when we hit the create server call below:
Code: InvalidAuthConfigParameterCombinationValue
Message: The provided combination of values for ActiveDirectoryAuthEnabled as false and PasswordAuthEnabled as false is not supported
'host': host, | ||
'database': database, | ||
} | ||
return 'postgresql://{user}@{host}/{database}?sslmode=require'.format(**connection_kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's turn this postgresql://{user}@{host}/{database}?sslmode=require'.format(**connection_kwargs)
into this postgresql://{user}:<access-token>@{host}/{database}?sslmode=require'.format(**connection_kwargs)
.
Also, user must be percent encoded, because the URI parser in Postgres identifies the first @
as the point at which the user/password part ends and the host begins. So, in a case like postgresql://ialonso@microsoft.com@server.postgres.database.azure.com/database?sslmode=require
, the client that attempts to use that connection string would assume that the name of the host is microsoft.com@server.postgres.database.azure.com
, which is incorrect. However, if we percent-encode the @
as in postgresql://ialonso%40microsoft.com@server.postgres.database.azure.com/database?sslmode=require
, then it would work.
Related command
az postgres flexible-server create
Description
Fix when during flexible-server create makes a password when --password-auth Disabled.
Update text that reference active directory auth and change to Microsoft Entra
Add ability to add admin during create if Microsoft Entra is enabled
Testing Guide
az postgres flexible-server create -h
az postgres flexible-server create -g testGroup -n test-default --location location
az postgres flexible-server create -g testGroup -n test-msentra --location location --create-default-database Disabled --active-directory-auth Enabled
az postgres flexible-server create -g testGroup -n test-msentra-only --location location --create-default-database Disabled --active-directory-auth Enabled --password-auth Disabled
az postgres flexible-server create -g testGroup -n test-msentra-admin --location location --create-default-database 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
az postgres flexible-server create -g testGroup -n test-msentra-password-admin --location location --create-default-database Disabled --active-directory-auth Enabled --admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name john@contoso.com --admin-type User
az postgres flexible-server create -g testGroup -n nasc-test --location location --create-default-database Disabled --admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name john@contoso.com --admin-type User
To provide values for --admin-object-id, --admin-display-name, and --admin-type please set --active-directory-auth to "Enabled".
az postgres flexible-server create -g testGroup -n nasc-test7 --location location --create-default-database Disabled --active-directory-auth Enabled --admin-object-id 00000000-0000-0000-0000-000000000000 --admin-display-name john@contoso.com
To add Microsoft Entra admin, please provide values for --admin-object-id, --admin-display-name, and --admin-type.
History Notes
[RDBMS]
az postgres flexible-server create
: Bug fix, no longer generate password when--password-auth
is Disabled. Support adding admin during create if--active-directory-auth
is Enabled.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.