To create a PostgreSQL database in Azure using the Azure CLI, you will need to have the Azure CLI installed on your computer and be logged in to your Azure account.
To create a PostgreSQL database, you can use the az postgres server create
command, which has the following syntax:
az postgres server create --name --resource-group --location --admin-user --admin-password
Here’s an example of how you could use this command to create a PostgreSQL database called my_database
in the eastus
region:
az postgres server create --name my_database --resource-group my_resource_group --location eastus --admin-user my_username --admin-password my_password
This command will create a new PostgreSQL server and database, and assign the specified admin username and password. You can then use these credentials to connect to the database using any PostgreSQL client, such as Azure Data Studio or the psql
command-line interface.