Skip to content

Conversation

@mattboentoro
Copy link
Contributor

@mattboentoro mattboentoro commented Dec 22, 2025

… for create

Related command
az postgres flexible-server create

Description
Added database name field for create with cluster

Testing Guide
image

History Notes

[RDBMS] az postgres flexible-server create: Add database name field for create with cluster


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings December 22, 2025 18:23
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Dec 22, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Dec 22, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️rdbms
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd postgres flexible-server create cmd postgres flexible-server create added parameter database_name

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 22, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a --database-name parameter to the az postgres flexible-server create command, allowing users to specify a custom database name when creating an elastic cluster. When not provided, the database name defaults to 'postgres'.

Key Changes

  • Added database_name parameter to the flexible_server_create function signature
  • Integrated the parameter into elastic cluster creation logic to set custom default database names

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
flexible_server_custom_postgres.py Added database_name parameter to function signature and used it in elastic cluster creation to set the default database name
_params.py Registered the database_name argument for the postgres flexible-server create command using the pre-existing database_name_create_arg_type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if create_cluster == 'ElasticCluster':
cluster_size = cluster_size if cluster_size else 2
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=POSTGRES_DB_NAME)
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=database_name if database_name else POSTGRES_DB_NAME)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database_name parameter is used here without being validated by the pg_arguments_validator function. The validator function (defined in validators.py) accepts a database_name parameter and performs format validation to ensure it begins with a letter or underscore, contains only valid characters (letters, digits, hyphens, underscores), and is less than 64 characters. You should add database_name=database_name to the validator call above (around line 112-136) to ensure invalid database names are caught early with a proper error message rather than failing later in the process.

Copilot uses AI. Check for mistakes.
Comment on lines 139 to +141
if create_cluster == 'ElasticCluster':
cluster_size = cluster_size if cluster_size else 2
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=POSTGRES_DB_NAME)
cluster = postgresql_flexibleservers.models.Cluster(cluster_size=cluster_size, default_database_name=database_name if database_name else POSTGRES_DB_NAME)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database_name parameter is only used when creating an elastic cluster (create_cluster == 'ElasticCluster'). This means if a user provides the --database-name parameter when creating a regular server (not an elastic cluster), it will be silently ignored. Consider either: (1) adding validation to reject the parameter when not creating an elastic cluster with a clear error message, or (2) updating the help text for the parameter to clearly indicate it only applies to elastic clusters to avoid user confusion.

Copilot uses AI. Check for mistakes.
@mattboentoro mattboentoro changed the title [RDBMS] az postgres flexible-server create: Added database name field for create [RDBMS] az postgres flexible-server create: Add database name field for create Dec 22, 2025
@mattboentoro mattboentoro requested a review from nasc17 December 22, 2025 20:25
@mattboentoro mattboentoro changed the title [RDBMS] az postgres flexible-server create: Add database name field for create [RDBMS] az postgres flexible-server create: Add database name field for create with cluster Dec 23, 2025
@mattboentoro
Copy link
Contributor Author

@evelyn-ys do you mind reviewing this PR?

@evelyn-ys
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys evelyn-ys merged commit d46c829 into Azure:dev Dec 23, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants