Azure Database for PostgreSQL flexible server is a managed service that allows you to run, manage, and scale highly available PostgreSQL databases in the cloud.
This article shows you how to create an Azure Database for PostgreSQL flexible server using different mechanisms.
If you don't have an Azure subscription, create a free Azure account before you begin.
Select any of the following tabs, depending on the method you want to use to deploy your instance:
Using the Azure portal:
Sign in with your credentials, if you're asked to do so.
Select Create a resource in the upper-left corner of the portal.
Under Categories, select Databases.
From the filtered list of resource types, find the one called Azure Database for PostgreSQL flexible server.
Select Create.
The New Azure Database for PostgreSQL flexible server wizard launches.
Provide all information required, starting from the Basics tab.
Use the following table to understand the meaning of the different fields available in the Basics page, and as guidance to fill the page:
Section Setting Suggested value Description Can be changed after instance creation Project details Subscription Select the name of the subscription in which you want to create the resource. A subscription is an agreement with Microsoft to use one or more Microsoft cloud platforms or services, for which charges accrue based on either a per-user license fee or on cloud-based resource consumption. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource. An existing Azure Database for PostgreSQL flexible server instance can be moved to a different subscription from the one it was originally created. For more information, see Move Azure resources to a new resource group or subscription. Resource group The resource group in the selected subscription, in which you want to create the resource. It can be an existing resource group, or you can select Create new, and provide a name in that subscription which is unique among the existing resource group names. A resource group is a container that holds related resources for an Azure solution. The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. You decide how you want to allocate resources to resource groups based on what makes the most sense for your organization. Generally, add resources that share the same lifecycle to the same resource group so you can easily deploy, update, and delete them as a group An existing Azure Database for PostgreSQL flexible server instance can be moved to a different subscription from the one it was originally created. For more information, see Move Azure resources to a new resource group or subscription. Server details Server name The name that you want to assign to the server. A unique name that identifies your Azure Database for PostgreSQL flexible server instance. The domain namepostgres.database.azure.com
is appended to the server name you provide, to conform the fully qualified host name by which you can use a Domain Naming System server to resolve the IP address of your instance. Although the server name can't be changed after server creation, you can use the point in time recovery feature, to restore the server under a different name. An alternative approach to continue using the existing server, but being able to refer to it using a different server name, would use the virtual endpoints to create a writer endpoint with the new desired name. With this approach, you could refer to the instance by its original name, or that assigned to the write virtual endpoint. Region The name of one of the regions in which the service is supported, and is more adequate for you to deploy your instance. Compliance, data residency, pricing, proximity to your users, or availability of other services in the same region, are some of the requirements you should use when choosing the region. The service doesn't offer a feature to automatically and transparently relocate an instance to a different region. PostgreSQL version The version selected by default. You can select among the list of major versions of PostgreSQL currently supported by the service. Currently those versions are: 17, 16, 15, 14, 13, 12, 11 Workload type Default SKU selection. You can choose from Development
(Burstable SKU), Production
(General Purpose, by default, or Memory Optimized SKUs). You can further customize the SKU and storage by selecting Configure server. The service provides a built-in feature which can upgrade the current major version of your instance to any other higher version supported by the feature. For more information, see major version upgrades. Availability zone Your preferred availability zone. You can choose in which availability zone you want your server to be deployed. Being able to choose the availability zone in which your instance is deployed, is useful to colocate it with your application. If you choose No preference, a default availability zone is automatically assigned to your instance during its creation. Although the availability zone in which an instance is deployed can't be changed after its creation, you can use the point in time recovery feature to restore the server under a different name on a different availability zone. High availability High availability Enable it for Same zone or Zone redundant. If you select either of these two options, a standby server with the same configuration as your primary is automatically provisioned. The standby server is provisioned in the same availability zone or in a different availability zone within the same region, depending on the option selected. Notice that high availability can be enabled or disabled after the server is created. High availability can be enabled or disabled after server creation. However, if it's enabled, it can't be changed directly from Same zone to Zone redundant or vice versa. In order to implement such change, you first need to disable high availability, and then re-enable it choosing the newly desired mode. Authentication Authentication method Although the recommended authentication method is Microsoft Entra authentication, for the sake of simplicity, in this quickstart let's select PostgreSQL authentication only. By selecting PostgreSQL authentication only, you're required to provide a PostgreSQL native user name and a password. If you choose Microsoft Entra authentication, you need to provide the object identifier of the Microsoft Entra user or group which you want to assign as the administrator of the instance. If you choose, PostgreSQL and Microsoft Entra authentication, you need to satisfy both previous requirements. Can be changed to any of the three supported values after server creation. Administrator login The name of the PostgreSQL native user that you want to assign as the administrator of your instance. For this example, let's set it to adminuser
. The admin username must contain between 1 and 63 characters, must only consist of numbers and letters, canât start with pg_ and can't be azure_superuser, azure_pg_admin, admin, administrator, root, guest, or public. The name of this user can't be changed after the instance is created. Also, it can't be replaced with some other PostgreSQL native user that you could create in the instance. Password The password that you want to assign to the PostgreSQL native user which is designated as an administrator. Specify a password for the server admin account. Make sure that your password is complex enough. Can be changed as many times as needed after the server is created. Confirm password The password that you want to assign to the PostgreSQL native user which is designated as an administrator. Must match the value assign to Password. Can be changed as many times as needed after the server is created.To configure the compute and storage further, under Server details, in the Compute + storage section, select Configure server. The Compute + storage page opens, where you can configure several settings specific to the type of compute and storage you want to use. Once you configure your compute and storage according to your needs, select Save to return to the Basics page and continue configuring your instance.
Use the following table to understand the meaning of the different fields available in the Compute + storage page, and as guidance to fill the page:
Section Setting Suggested value Description Can be changed after instance creation Cluster Cluster options Select Server. Possible values are Server (for workloads that can fit on one node) and Elastic cluster (for capacity larger than a single node, elastic cluster provides schema- and row-based sharding on a database distributed across a cluster). Can't be changed on existing servers. Node count Set it to 4. This option is only available when Cluster options is set to Elastic cluster. Allowed range of values span from 1 to 10. Can be changed on existing servers. Compute Compute tier Select General Purpose. Possible values are Burstable (typically used for development environments in which workloads don't need the full capacity of the CPU continuously) and General Purpose (typically used for production environments with most common workloads), and Memory Optimized (typically used for production environments running workloads that require a high memory to CPU ratio). For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after the server is created. However, if you're using some functionality which is only supported on certain tiers, and change the current tier to one in which the feature isn't supported, the feature stops being available or gets disabled. Compute processor Leave the default setting. Notice that this option might not be visible for some regions. If the region selected in the Basics tab supports processors from more than one manufacturer, then the option is visible. In the regions supporting processors from different manufacturers, possible values are AMD and Intel. For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed for existing instances, as long as the region in which the instance is deployed offers processors from more than one manufacturer. Compute size Leave the default setting. Notice that the list of supported values might vary across regions, depending on the hardware available on each region. For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after instance is created. Storage Storage type Select Premium SSD. Notice that the list of allowed values might vary depending on which other features you selected. For more information, see Storage options in Azure Database for PostgreSQL flexible server. Can't be changed after the instance is created. Storage size Leave the default setting. Notice that the list of supported values might vary across regions, depending on the hardware available on each region. For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after the instance is created. It can only be increased. Manual or automatic shrinking of storage isn't supported. Acceptable values depend on the type of storage assigned to the instance. Performance tier Leave the default setting. Performance of Premium solid-state drives (SSD) is set when you create the disk, in the form of their performance tier. When setting the provisioned size of the disk, a performance tier is automatically selected. This performance tier determines the IOPS and throughput of your managed disk. For Premium SSD disks, this tier can be changed at deployment or afterwards, without changing the size of the disk, and without downtime. Changing the tier allows you to prepare for and meet higher demand without using your disk's bursting capability. It can be more cost-effective to change your performance tier rather than rely on bursting, depending on how long the extra performance is necessary. This is ideal for events that temporarily require a consistently higher level of performance, like holiday shopping, performance testing, or running a training environment. To handle these events, you can switch a disk to a higher performance tier without downtime, for as long as you need the extra performance. You can then return to the original tier without downtime when the extra performance is no longer necessary. Can be changed after the instance is created. Storage autogrow Select this option to enable the autogrow feature. Notice that this option might not be supported for some storage types, and it might not be honored for certain storage sizes. For more information, see Configure storage autogrow in an Azure Database for PostgreSQL flexible server. Can be changed after the instance is created, as long as the storage type supports this feature. High availability High availability Leave the value that is selected by default. Supported values are Disabled (99.9% SLA), Same zone (99.95% SLA), and Zone redundant (99.99% SLA). Notice that supported high availability options might vary depending on the region in which you're trying to deploy your instance. For more information, see High availability in Azure Database for PostgreSQL flexible server. High availability can be enabled or disabled after server creation. However, if it's enabled, it can't be changed directly from Same zone to Zone redundant or viceversa. In order to implement such change, you first need to disable high availability, and then re-enable it choosing the newly desired mode. Backups Backup retention period (in days) Leave the value that is selected by default. The default backup retention period is 7 days, but you can extend the period to a maximum of 35 days. Notice that supported high availability options might vary depending on the region in which you're trying to deploy your instance. For more information, see High availability in Azure Database for PostgreSQL flexible server. Can be changed after instance is created. Backup redundancy Automatically selected for you, based on whether or not the selected region supports multiple availability zones, and the configuration of the geographical redundancy of backups. Possible values are Locally redundant (provides at least 99.999999999% durability of backup objects over a year), Zone redundant (provides at least 99.9999999999% durability of backup objects over a year), and Geo-Redundant (provides at least 99.99999999999999% durability of backup objects over a year). When Geo-redundancy is enabled for the backup, then the backup redundancy option is set to Geo-Redundant. Otherwise, if the region doesn't support multiple availability zones, then backup redundancy is set to Locally redundant. And if the region supports multiple availability zones, then backup redundancy is set to Zone redundant. For more information, see Backup redundancy options in Azure Database for PostgreSQL flexible server. Can't be changed after instance is created. Geo-redundancy Leave this option disabled. Geo-redundancy in backups is only supported on instances deployed in any of the Azure paired regions. For more information, see Geo-redundant backup and restore in Azure Database for PostgreSQL flexible server Can't be changed after instance is created.After providing all required information in the Basics tab, select Next: Networking to move forward to the Network tab, from where you can configure the networking settings of your Azure Database for PostgreSQL flexible server instance:
Use the following table to understand the meaning of the different fields available in the Networking page, and as guidance to fill the page:
After providing all required information in the Networking tab, select Next: Security to move forward to the Security tab, from where you can configure the data security settings of your Azure Database for PostgreSQL flexible server instance:
Use the following table to understand the meaning of the different fields available in the Security page, and as guidance to fill the page:
Section Setting Suggested value Description Can be changed after instance creation Data encryption Data encryption key Leave the default setting. Possible values are Service-managed key and Customer-managed key. For more information, see Data encryption in Azure Database for PostgreSQL flexible server. Can't be changed after instance is created.After providing all required information in the Security tab, select Next: Tags to move forward to the Tags tab, from where you can attach some tags to your Azure Database for PostgreSQL flexible server instance:
Use the following table to understand the meaning of the different fields available in the Tags page, and as guidance to fill the page:
Section Setting Suggested value Description Can be changed after instance creation Name Set it toEnvironment
. For more information about, see tags. Can be changed after instance is created. Value Set it to PostgreSQL Quickstart
. For more information about, see tags. Can be changed after instance is created.After providing all required information in the Tags tab, select Next: Review + create to move forward to the Review + create tab, from where you can review all settings configured for your new Azure Database for PostgreSQL flexible server instance, before you trigger its creation:
After reviewing that the values of all settings match your requirements, select Create to initiate the deployment of your new Azure Database for PostgreSQL flexible server instance:
A new deployment is launched to create your Azure Database for PostgreSQL flexible server instance:
When the deployment completes, you can select Go to resource, to get you to the Overview page of your new Azure Database for PostgreSQL flexible server instance, and start using it:
The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.
To open the Cloud Shell, just select Open Cloud Shell from the upper right corner of a code block. You can also open Cloud Shell in a separate browser tab, by going to https://shell.azure.com/bash. Select Copy to copy the blocks of code, paste them into the Cloud Shell, and select Enter to run them.
If you prefer to install and use Azure CLI locally, this quickstart requires version 2.67.0 or later. Run az --version
to find the version currently installed. If you need to install or upgrade Azure CLI, see Install Azure CLI.
You need to log in to your account using the az login command. Note the id
property in the output, which refers to the Subscription ID for your Azure account.
az login
Create an Azure Database for PostgreSQL flexible server instance, using the az postgres flexible-server create command.
az postgres flexible-server create \
--subscription <subscription> \
--resource-group <resource-group> \
--name <name> \
--location <region> \
--version <version> \
--zone <zone> \
--password-auth <password-auth> \
--admin-user <admin-user> \
--admin-password <admin-password> \
--tier <tier> \
--sku-name <sku-name> \
--storage-type <storage-type> \
--storage-size <storage-size> \
--performance-tier <performance-tier> \
--storage-auto-grow <storage-auto-grow> \
--high-availability <high-availability> \
--standby-zone <standby-zone> \
--backup-retention <backup-retention> \
--geo-redundant-backup <geo-redundant-backup> \
--public-access <public-access> \
--tags <tags>
Use the following table to understand the meaning of each different parameter, and as guidance to provide values for each of them:
Parameter Suggested value Description Can be changed after instance creation subscription Enter the name or identifier of the subscription in which you want to create the resource. A subscription is an agreement with Microsoft to use one or more Microsoft cloud platforms or services, for which charges accrue based on either a per-user license fee or on cloud-based resource consumption. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource. An existing Azure Database for PostgreSQL flexible server instance can be moved to a different subscription from the one it was originally created. For more information, see Move Azure resources to a new resource group or subscription. resource-group The resource group in the selected subscription, in which you want to create the resource. It can be an existing resource group or, if it doesn't exist, it's created. A resource group is a container that holds related resources for an Azure solution. The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. You decide how you want to allocate resources to resource groups based on what makes the most sense for your organization. Generally, add resources that share the same lifecycle to the same resource group so you can easily deploy, update, and delete them as a group An existing Azure Database for PostgreSQL flexible server instance can be moved to a different subscription from the one it was originally created. For more information, see Move Azure resources to a new resource group or subscription. name The name that you want to assign to the server. A unique name that identifies your Azure Database for PostgreSQL flexible server instance. The domain namepostgres.database.azure.com
is appended to the server name you provide, to conform the fully qualified host name by which you can use a Domain Naming System server to resolve the IP address of your instance. Although the server name can't be changed after server creation, you can use the point in time recovery feature, to restore the server under a different name. An alternative approach to continue using the existing server but being able to refer to it using a different server name, would use the virtual endpoints to create a writer endpoint with the new desired name. With this approach, you could refer to the instance by its original name, or that assigned to the write virtual endpoint. region The name of one of the regions in which the service is supported, and is more adequate for you to deploy your instance. Compliance, data residency, pricing, proximity to your users, or availability of other services in the same region, are some of the requirements you should use when choosing the region. The service doesn't offer a feature to automatically and transparently relocate an instance to a different region. version The version selected by default. You can select among the list of major versions of PostgreSQL currently supported by the service. Currently those versions are: 17, 16, 15, 14, 13, 12, 11 zone Set it to 1
. This number represents your preferred logical availability zone. You can choose in which availability zone you want your server to be deployed. Being able to choose the availability zone in which your instance is deployed, is useful to colocate it with your application. If you don't specify this parameter, a default availability zone is automatically assigned to your instance during its creation. Although the availability zone in which an instance is deployed can't be changed after its creation, you can use the point in time recovery feature to restore the server under a different name on a different availability zone. password-auth Set it to enabled
. Although the recommended authentication method is Microsoft Entra authentication, which you can configure using the --active-directory-auth
parameter, for the sake of simplicity, in this quickstart let's select use PostgreSQL authentication. By selecting setting this parameter to enabled
, you're required to also provide values for the --admin-user
and --admin-password
parameters. If you set --active-directory-auth
to enabled
, you can use the az postgres flexible-server ad-admin commands to create or remove Microsoft Entra users or groups as PostgreSQL administrators. Can be enabled or disabled after server creation. admin-user The name of the PostgreSQL native user that you want to assign as the administrator of your instance. For this example, let's set it to adminuser
. The admin username must contain between 1 and 63 characters, must only consist of numbers and letters, canât start with pg_ and can't be azure_superuser, azure_pg_admin, admin, administrator, root, guest, or public. The name of this user can't be changed after the instance is created. Also, it can't be replaced with some other PostgreSQL native user that you could create in the instance. admin-password The password that you want to assign to the PostgreSQL native user which is designated as an administrator. Specify a password for the server admin account. Make sure that your password is complex enough. Can be changed as many times as needed after the server is created. tier Set it to generalpurpose
. Possible values are burstable
(typically used for development environments in which workloads don't need the full capacity of the CPU continuously), generalpurpose
(typically used for production environments with most common workloads), and memoryoptimized
(typically used for production environments running workloads that require a high memory to CPU ratio). For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after the server is created. However, if you're using some functionality which is only supported on certain tiers, and change the current tier to one in which the feature isn't supported, the feature stops being available or gets disabled. sku-name Set it to standard_d4ds_v5
. Notice that the list of supported values might vary across regions, depending on the hardware available on each region. For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after instance is created. storage-type Set it to premium_lrs
. Notice that the list of allowed values might vary depending on which other features you selected. For more information, see Storage options in Azure Database for PostgreSQL flexible server. Can't be changed after the instance is created. storage-size Set it to 128
. Notice that the list of supported values might vary across regions, depending on the hardware available on each region. For more information, see Compute options in Azure Database for PostgreSQL flexible server. Can be changed after the instance is created. It can only be increased. Manual or automatic shrinking of storage isn't supported. Acceptable values depend on the type of storage assigned to the instance. performance-tier Set it to p10
. Performance of Premium solid-state drives (SSD) is set when you create the disk, in the form of their performance tier. When setting the provisioned size of the disk, a performance tier is automatically selected. This performance tier determines the IOPS and throughput of your managed disk. For Premium SSD disks, this tier can be changed at deployment or afterwards, without changing the size of the disk, and without downtime. Changing the tier allows you to prepare for and meet higher demand without using your disk's bursting capability. It can be more cost-effective to change your performance tier rather than rely on bursting, depending on how long the extra performance is necessary. This is ideal for events that temporarily require a consistently higher level of performance, like holiday shopping, performance testing, or running a training environment. To handle these events, you can switch a disk to a higher performance tier without downtime, for as long as you need the extra performance. You can then return to the original tier without downtime when the extra performance is no longer necessary. Can be changed after the instance is created. storage-auto-grow Set it to enabled
. Notice that this option might not be supported for some storage types, and it might not be honored for certain storage sizes. For more information, see Configure storage autogrow in an Azure Database for PostgreSQL flexible server. Can be changed after the instance is created, as long as the storage type supports this feature. high-availability Set it to zoneredundant
. Supported values are disabled (99.9% SLA), samezone (99.95% SLA), and zoneredundant (99.99% SLA). Notice that supported high availability options might vary depending on the region in which you're trying to deploy your instance. For more information, see High availability in Azure Database for PostgreSQL flexible server. High availability can be enabled or disabled after server creation. However, if it's enabled, it can't be changed directly from samezone to zoneredundant or viceversa. In order to implement such change, you first need to disable high availability, and then re-enable it choosing the newly desired mode. standby-zone Set it to 2
. This number represents your preferred logical availability zone for the hot standby replica. You can choose in which availability zone you want your server to be deployed. Being able to choose the availability zone in which your instance is deployed, is useful to colocate it with your application. If you choose No preference, a default availability zone is automatically assigned to your instance during its creation. Although the availability zone in which an instance is deployed can't be changed after its creation, you can use the point in time recovery feature to restore the server under a different name on a different availability zone. backup-retention Set it to 7
. The default backup retention period is 7 days, but you can extend the period to a maximum of 35 days. Notice that supported high availability options might vary depending on the region in which you're trying to deploy your instance. For more information, see High availability in Azure Database for PostgreSQL flexible server. Can be changed after instance is created. geo-redundant-backup Set it to disabled
. Geo-redundancy in backups is only supported on instances deployed in any of the Azure paired regions. For more information, see Geo-redundant backup and restore in Azure Database for PostgreSQL flexible server Can't be changed after instance is created. public-access Set it to $(curl ipinfo.io/ip)
to create a firewall rule that allowlists the public IP address of the computer from which you're running the Azure CLI commands. That allows you to connect to your new instance from that computer. Possible values are all
, none
, <startIpAddress>
, or <startIpAddress>-<endIpAddress>
. For more information, see Network with public access and private endpoints for Azure Database for PostgreSQL flexible server with public access and Network with virtual network integration for Azure Database for PostgreSQL flexible server. Can't be changed after instance is created. tags Set it to "Environment=PostgreSQL Quickstart"
. For more information about, see tags. Can be changed after instance is created.If the deployment completes successfully, you should receive an output from the CLI command like the following:
{
"connectionString": "postgresql://<admin-user>:<admin-password>@<name>.postgres.database.azure.com/None?sslmode=require",
"databaseName": null,
"firewallName": "FirewallIPAddress_<timestamp>",
"host": "<name>.postgres.database.azure.com",
"id": "/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.DBforPostgreSQL/flexibleServers/<name>",
"location": "<region>",
"password": "<admin-password>",
"resourceGroup": "<reource-group>",
"skuname": "<sku-name>",
"username": "<admin-user>",
"version": "<version>"
}
An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.
Azure Resource Manager is the deployment and management service for Azure. It provides a management layer that enables you to create, update, and delete resources in your Azure account. You use management features, like access control, locks, and tags, to secure and organize your resources after deployment. To learn about Azure Resource Manager templates, see Template deployment overview.
An Azure Database for PostgreSQL flexible server instance is the parent resource for one or more databases within a region. It provides the scope for management policies that apply to its databases: login, firewall, users, roles, and configurations.
Create a file called postgres-flexible-server-template.json
, and copy the following JSON definition into it.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "string"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"version": {
"type": "string",
"defaultValue": "16"
},
"availabilityZone": {
"type": "string",
"defaultValue": "1"
},
"activeDirectoryAuth": {
"type": "string",
"defaultValue": "Disabled"
},
"passwordAuth": {
"type": "string",
"defaultValue": "Enabled"
},
"administratorLogin": {
"type": "string",
"defaultValue": "adminuser"
},
"administratorLoginPassword": {
"type": "secureString"
},
"skuTier": {
"type": "string",
"defaultValue": "GeneralPurpose"
},
"skuName": {
"type": "string",
"defaultValue": "Standard_D4ds_v5"
},
"storageType": {
"type": "string",
"defaultValue": "Premium_LRS"
},
"storageSizeGB": {
"type": "int",
"defaultValue": 128
},
"storageTier": {
"type": "string",
"defaultValue": "P10"
},
"storageAutoGrow": {
"type": "string",
"defaultValue": "Enabled"
},
"highAvailabilityMode": {
"type": "string",
"defaultValue": "ZoneRedundant"
},
"standbyAvailabilityZone": {
"type": "string",
"defaultValue": "2"
},
"backupRetentionDays": {
"type": "int",
"defaultValue": 7
},
"geoRedundantBackup": {
"type": "string",
"defaultValue": "Disabled"
},
"publicNetworkAccess": {
"type": "string",
"defaultValue": "Enabled"
},
"tags": {
"type": "object",
"defaultValue": {
"Environment": "PostgreSQL Quickstart"
}
},
"firewallRules": {
"type": "array"
}
},
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/flexibleServers",
"apiVersion": "2024-08-01",
"name": "[parameters('serverName')]",
"location": "[parameters('location')]",
"sku": {
"tier": "[parameters('skuTier')]",
"name": "[parameters('skuName')]"
},
"properties": {
"version": "[parameters('version')]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"authConfig": {
"activeDirectoryAuth": "[parameters('activeDirectoryAuth')]",
"passwordAuth": "[parameters('passwordAuth')]"
},
"network": {
"publicNetworkAccess": "[parameters('publicNetworkAccess')]"
},
"highAvailability": {
"mode": "[parameters('highAvailabilityMode')]",
"standbyAvailabilityZone": "[parameters('standbyAvailabilityZone')]"
},
"storage": {
"autoGrow": "[parameters('storageAutoGrow')]",
"storageSizeGB": "[parameters('storageSizeGB')]",
"tier": "[parameters('storageTier')]",
"type": "[parameters('storageType')]"
},
"backup": {
"backupRetentionDays": "[parameters('backupRetentionDays')]",
"geoRedundantBackup": "[parameters('geoRedundantBackup')]"
},
"availabilityZone": "[parameters('availabilityZone')]",
"tags": "[parameters('tags')]"
}
},
{
"copy": {
"name": "createFirewallRules",
"count": "[length(range(0, if(greater(length(parameters('firewallRules')), 0), length(parameters('firewallRules')), 1)))]",
"mode": "serial",
"batchSize": 1
},
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "[format('firewallRules-{0}', range(0, if(greater(length(parameters('firewallRules')), 0), length(parameters('firewallRules')), 1))[copyIndex()])]",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
},
"mode": "Incremental",
"parameters": {
"ip": {
"value": "[parameters('firewallRules')[range(0, if(greater(length(parameters('firewallRules')), 0), length(parameters('firewallRules')), 1))[copyIndex()]]]"
},
"serverName": {
"value": "[parameters('serverName')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "string"
},
"ip": {
"type": "object"
}
},
"resources": [
{
"type": "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules",
"apiVersion": "2024-08-01",
"name": "[format('{0}/{1}', parameters('serverName'), parameters('ip').name)]",
"properties": {
"startIpAddress": "[parameters('ip').startIPAddress]",
"endIpAddress": "[parameters('ip').endIPAddress]"
}
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.DBforPostgreSQL/flexibleServers', parameters('serverName'))]"
]
}
]
}
These resources are defined in the Microsoft.DBforPostgreSQL/flexibleServers and Microsoft.DBforPostgreSQL/flexibleServers/firewallRules templates.
Select Open Cloud Shell from the following code block, to open Azure Cloud Shell. Copy and paste the code, replace the argument placeholders with your own values, and select Enter.
az group create --name <resource-group> --location <region>
az deployment group create --name QuickstartAzureDatabaseForPostgreSQLFlexibleServer --resource-group <resource-group> --template-file <path-to-template-file> --parameters serverName=<server> administratorLoginPassword=<admin-password> firewallRules="[{'name':'ClientIPAddress','startIPAddress':'$(curl ipinfo.io/ip)','endIPAddress':'$(curl ipinfo.io/ip)'}]"
By default, a database called postgres is created in your instance. The postgres database is a default database that's meant for use by users, utilities, and third-party applications.
A second database that is created on every instance is azure_maintenance. Although you can connect to this database, you have minimum permissions granted so you can barely do anything in it.
Finally, there's database azure_sys, which is used to host some objects used by features like query store and index tuning.
To connect to your instance, you need to have its fully qualified name and the credentials of the user with which you want to connect. You should have noted those values from when you deployed the instance, earlier in this article. If you didn't, you can retrieve everything but the password of the administrator user. If you forgot the password assigned to your instance, you can always reset it. To learn how to do it, see reset admin password.
Using the Azure portal:
Open the Overview page of your new instance.
Copy the value of Endpoint, and save it somewhere to use it later. Hover your cursor over each field, and the copy symbol appears to the right of the text. Select the copy symbol as needed to copy the values.
Copy the value of Administrator login, and save it somewhere to use it later. Hover your cursor over each field, and the copy symbol appears to the right of the text. Select the copy symbol as needed to copy the values.
The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.
To open the Cloud Shell, just select Open Cloud Shell from the upper right corner of a code block. You can also open Cloud Shell in a separate browser tab, by going to https://shell.azure.com/bash. Select Copy to copy the blocks of code, paste them into the Cloud Shell, and select Enter to run them.
If you prefer to install and use Azure CLI locally, this quickstart requires version 2.67.0 or later. Run az --version
to find the version currently installed. If you need to install or upgrade Azure CLI, see Install Azure CLI.
Run the following command to retrieve the fully qualified name of the instance and the name of the administrator user:
az postgres flexible-server show \
--resource-group <resource-group> \
--name <server> \
--query "{serverName:fullyQualifiedDomainName, adminUser:administratorLogin}" \
--output table
There are many applications you can use to connect to your Azure Database for PostgreSQL flexible server instance. If your client computer has PostgreSQL installed, you can use a local instance of psql to connect to an Azure Database for PostgreSQL flexible server instance. If it isn't installed on your machine, download the ready-to-use package that targets your platform and install it.
Once installed, you can use the psql command-line utility to connect to the Azure Database for PostgreSQL flexible server instance.
You connected to the Azure Database for PostgreSQL flexible server instance via psql, and you created a blank user database.
You can clean up the resources that you created in this quickstart in one of two ways. You can delete the Azure resource group, which includes all the resources in the resource group. If you want to keep other resources deployed in the same resource group intact, you can delete only the Azure Database for PostgreSQL flexible server instance.
Using the Azure portal:
To delete the entire resource group, including the newly created server.
Select Resource groups.
Search for the resource group that you want to delete, and select its name.
In the Overview page of the resource group chosen, select Delete resource group.
Enter the name of the resource group in the Enter resource group name to confirm deletion text box.
Select Delete.
To delete only the newly created server.
Locate your server in the portal, if you don't have it open. One way to do it is by typing the name of the server in the search bar. When the resource with the matching name is shown, select that resource.
In the Overview page, select Delete.
Select I have read and understand that this server, as well as any databases it contains, will be deleted..
Select Delete.
To delete the entire resource group, including the newly created server, execute the following command:
az group delete --name <resource-group>
To delete only the newly created server, execute the following command:
az postgres flexible-server delete \
--resource-group <resource-group> \
--name <name>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4