Skip to content

Azure Docs: DB for PostgreSQL#561

Open
HarshCasper wants to merge 1 commit intomainfrom
postgres-azure
Open

Azure Docs: DB for PostgreSQL#561
HarshCasper wants to merge 1 commit intomainfrom
postgres-azure

Conversation

@HarshCasper
Copy link
Copy Markdown
Member

Fixes DOC-163

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying localstack-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4d02fc1
Status: ✅  Deploy successful!
Preview URL: https://db36d7dc.localstack-docs.pages.dev
Branch Preview URL: https://postgres-azure.localstack-docs.pages.dev

View logs

@HarshCasper HarshCasper requested a review from a team April 15, 2026 09:57
Copy link
Copy Markdown
Contributor

@paolosalvatori paolosalvatori left a comment

Choose a reason for hiding this comment

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

Thanks @HarshCasper! I just realized 15 minutes ago that the Azure Database for PostgreSQL emulator has some bugs, so some of the commands that should be used, do not work properly. I need to fix these issues, then I'll proceed with the review. Stay tuned, on my way.

Copy link
Copy Markdown
Contributor

@paolosalvatori paolosalvatori left a comment

Choose a reason for hiding this comment

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

Hi @HarshCasper I had to fix some issues affecting the Azure Database for PostgreSQL flexible server emulator before reviewing the related article. You can now proceed to review my suggestions and additions. Thanks cc: @quetzalliwrites

@@ -1,11 +1,239 @@
---
title: "DB for PostgreSQL"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
title: "DB for PostgreSQL"
title: "Database for PostgreSQL Flexible Server"

---
title: "DB for PostgreSQL"
description: API coverage for Microsoft.DBforPostgreSQL in LocalStack for Azure.
description: Get started with Azure DB for PostgreSQL on LocalStack
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: Get started with Azure DB for PostgreSQL on LocalStack
description: Get started with Azure Database for PostgreSQL flexible server on LocalStack

Comment on lines +11 to +13
Azure DB for PostgreSQL is a managed relational database service built on the PostgreSQL engine.
It helps provision and operate PostgreSQL servers with Azure control plane APIs for server, database, and network management.
This service is commonly used for application backends that require PostgreSQL compatibility with managed infrastructure workflows. For more information, see [Azure Database for PostgreSQL documentation](https://learn.microsoft.com/en-us/azure/postgresql/).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Azure DB for PostgreSQL is a managed relational database service built on the PostgreSQL engine.
It helps provision and operate PostgreSQL servers with Azure control plane APIs for server, database, and network management.
This service is commonly used for application backends that require PostgreSQL compatibility with managed infrastructure workflows. For more information, see [Azure Database for PostgreSQL documentation](https://learn.microsoft.com/en-us/azure/postgresql/).
Azure Database for PostgreSQL flexible server is a fully managed relational database service that provides granular control over database configuration and tuning. It supports PostgreSQL community versions and offers built-in high availability, intelligent performance monitoring, and flexible scaling across Burstable, General Purpose, and Memory Optimized compute tiers. Common use cases include web applications, microservices backends, and analytics workloads that benefit from PostgreSQL's extensibility and standards compliance. For more information, see [What is Azure Database for PostgreSQL - Flexible Server?](https://learn.microsoft.com/azure/postgresql/flexible-server/overview).


### Create a resource group

Create a resource group for your PostgreSQL resources:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Create a resource group for your PostgreSQL resources:
Create a resource group to hold all resources created in this guide:


### Create and inspect a PostgreSQL flexible server

Create a flexible server:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Create a flexible server:
Create a Burstable-tier PostgreSQL 16 flexible server with 32 GB of storage:

Comment on lines +189 to +194
az postgres flexible-server firewall-rule create \
--resource-group rg-postgres-demo \
--name pgdoc96 \
--rule-name allow-local \
--start-ip-address 0.0.0.0 \
--end-ip-address 0.0.0.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
az postgres flexible-server firewall-rule create \
--resource-group rg-postgres-demo \
--name pgdoc96 \
--rule-name allow-local \
--start-ip-address 0.0.0.0 \
--end-ip-address 0.0.0.0
az postgres flexible-server firewall-rule create \
--resource-group rg-postgres-demo \
--name postgres-demo \
--rule-name allow-myip \
--start-ip-address 203.0.113.10 \
--end-ip-address 203.0.113.10

Comment on lines +198 to +204
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-postgres-demo/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgdoc96/firewallRules/allow-local",
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-postgres-demo/providers/Microsoft.DBforPostgreSQL/flexibleServers/pgdoc96/firewallRules/allow-local",
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-postgres-demo/providers/Microsoft.DBforPostgreSQL/flexibleServers/postgres-demo/firewallRules/allow-myip",
"name": "allow-myip",
"resourceGroup": "rg-postgres-demo",
"startIpAddress": "203.0.113.10",
"endIpAddress": "203.0.113.10",
"type": "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules"
}

Comment on lines +210 to +213
az postgres flexible-server firewall-rule show \
--resource-group rg-postgres-demo \
--name pgdoc96 \
--rule-name allow-local
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
az postgres flexible-server firewall-rule show \
--resource-group rg-postgres-demo \
--name pgdoc96 \
--rule-name allow-local
az postgres flexible-server firewall-rule show \
--resource-group rg-postgres-demo \
--name postgres-demo \
--rule-name allow-myip

Comment on lines +221 to +234
{
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
[
{
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
[
{
"name": "allow-local",
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0",
...
}
]
{
"name": "allow-myip",
"startIpAddress": "203.0.113.10",
"endIpAddress": "203.0.113.10",
...
}
[
{
"name": "allow-myip",
"startIpAddress": "203.0.113.10",
"endIpAddress": "203.0.113.10",
...
}
]

}
]
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
### View and update server configuration
View the current value of the `max_connections` configuration parameter:
```bash
az postgres flexible-server parameter show \
--resource-group rg-postgres-demo \
--server-name postgres-demo \
--name max_connections
```
```bash title="Output"
{
"allowedValues": "25-5000",
"dataType": "Integer",
"defaultValue": "100",
"description": "Sets the maximum number of concurrent connections.",
"documentationLink": "https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-postgres-demo/providers/Microsoft.DBforPostgreSQL/flexibleServers/postgres-demo/configurations/max_connections",
"isConfigPendingRestart": false,
"isDynamicConfig": false,
"isReadOnly": false,
"name": "max_connections",
"resourceGroup": "rg-postgres-demo",
"source": "system-default",
"type": "Microsoft.DBforPostgreSQL/flexibleServers/configurations",
"unit": "",
"value": "100"
}
```
Update `max_connections` to 200:
```bash
az postgres flexible-server parameter set \
--resource-group rg-postgres-demo \
--server-name postgres-demo \
--name max_connections \
--value 200 \
--source user-override
```
```bash title="Output"
{
"allowedValues": "25-5000",
"dataType": "Integer",
"defaultValue": "100",
"description": "Sets the maximum number of concurrent connections.",
"documentationLink": "https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-postgres-demo/providers/Microsoft.DBforPostgreSQL/flexibleServers/postgres-demo/configurations/max_connections",
"isConfigPendingRestart": true,
"isDynamicConfig": false,
"isReadOnly": false,
"name": "max_connections",
"resourceGroup": "rg-postgres-demo",
"source": "user-override",
"type": "Microsoft.DBforPostgreSQL/flexibleServers/configurations",
"unit": "",
"value": "200"
}
```
Non-dynamic parameters such as `max_connections` set `isConfigPendingRestart` to `true` after an update. A server restart applies the change.
### Stop, start, and restart a server
Stop the flexible server:
```bash
az postgres flexible-server stop \
--resource-group rg-postgres-demo \
--name postgres-demo
```
```bash title="Output"
Server will be automatically started after 7 days if you do not perform a manual start operation
```
Verify the server state is `Stopped`:
```bash
az postgres flexible-server show \
--name postgres-demo \
--resource-group rg-postgres-demo \
--query state \
--output tsv
```
```bash title="Output"
Stopped
```
Start the server again:
```bash
az postgres flexible-server start \
--resource-group rg-postgres-demo \
--name postgres-demo
```
```bash title="Output"
```
Restart the server to apply pending configuration changes:
```bash
az postgres flexible-server restart \
--resource-group rg-postgres-demo \
--name postgres-demo
```
```bash title="Output"
```
### Delete and verify
Delete the flexible server:
```bash
az postgres flexible-server delete \
--resource-group rg-postgres-demo \
--name postgres-demo \
--yes
```
```bash title="Output"
```
Then list all flexible servers to confirm the resource group is now empty:
```bash
az postgres flexible-server list \
--resource-group rg-postgres-demo
```
```bash title="Output"
[]
```
## Features
The PostgreSQL Flexible Server emulator supports the following features:
- **Server lifecycle management**: Create, get, update, list, and delete flexible servers with full ARM resource model support.
- **Stop, start, and restart**: Transition servers between Ready and Stopped states with proper state machine enforcement.
- **Database management**: Create, get, list, and delete user databases. Each database is backed by a real PostgreSQL instance.
- **Firewall rules**: Create, get, update, list, and delete IP-based firewall rules with address range validation.
- **Server configuration**: Get, list, and update over 14 PostgreSQL configuration parameters with data-type validation and restart-pending tracking.
- **SKU tiers**: Burstable, General Purpose, and Memory Optimized tiers with multiple SKU sizes per tier.
- **PostgreSQL versions**: Versions 13, 14, 15, 16, and 17 with in-place major version upgrade support.
- **Storage management**: Configurable storage from 32 GB to 16 TB with automatic tier mapping and storage auto-grow support.
- **Name availability check**: Validate server name uniqueness across subscriptions before creation.
- **Location capabilities**: Query available SKUs, storage sizes, and supported PostgreSQL versions per region.
- **Long-running operations**: Server create, delete, start, stop, and restart return `202 Accepted` with async operation tracking headers.
- **Bicep and Terraform support**: Deploy flexible servers, databases, and firewall rules using infrastructure-as-code templates.
## Limitations
- **Backup and restore**: Backup retention days and geo-redundant backup settings are stored but no actual backups are performed. Point-in-time restore is not supported.
- **Read replicas**: Replica properties are returned in the server response but replica creation and management are not implemented.
- **Microsoft Entra authentication**: The `authConfig.activeDirectoryAuth` property is stored but Active Directory authentication is not enforced.
- **Virtual network integration**: Delegated subnet and private DNS zone properties are accepted but VNet injection is not performed.
- **Private endpoint connections**: The property is returned in the response but private endpoint connectivity is not implemented.
- **High availability failover**: High availability mode and standby availability zone are stored but no failover mechanism is active.
- **Firewall rule enforcement**: Firewall rules are stored and queryable but are not enforced on actual database connections.
- **Storage auto-grow enforcement**: The auto-grow setting is stored but automatic storage expansion does not occur.
## Samples
Explore end-to-end examples in the [LocalStack for Azure Samples](https://github.com/localstack/localstack-azure-samples) repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants