Azure Database for PostgreSQL APIs

This documentation provides comprehensive API references for interacting with Azure Database for PostgreSQL. You can use these APIs to programmatically manage and monitor your PostgreSQL database instances in Azure.

Tip: For the latest updates and best practices, always refer to the official Azure SDK documentation and Azure REST API specifications.

SDK Reference

Azure provides Software Development Kits (SDKs) for various programming languages to simplify interaction with Azure services. These SDKs wrap the underlying REST API calls, providing a more idiomatic and developer-friendly experience.

REST API Reference

The Azure Database for PostgreSQL REST API allows you to manage PostgreSQL servers, databases, firewalls, operations, and more. It's a powerful way to integrate Azure PostgreSQL management into your custom applications and workflows.

The base URL for the PostgreSQL API is typically:

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/...

Key API Resources and Operations:

Resource Operations Description
Servers Create, Get, Update, Delete, List Manages PostgreSQL server instances.
Databases Create, Get, Delete, List Manages databases within a PostgreSQL server.
Firewall Rules Create, Get, Update, Delete, List Configures network access to your PostgreSQL server.
Operations List Lists all supported operations for Azure Database for PostgreSQL.
Replicas Create, Get, Delete, List Manages read replicas for high availability and read scale-out.

For detailed information on request/response formats, authentication, and specific endpoints, please refer to the official Azure Database for PostgreSQL REST API documentation.

CLI Commands

The Azure Command-Line Interface (CLI) provides a set of commands for managing Azure resources, including Azure Database for PostgreSQL.

You can install the Azure CLI from here.

Common commands include:

# Create a PostgreSQL server
az postgres server create --resource-group myResourceGroup --name myServer --location eastus --admin-user myadmin --admin-password mypassword

# List PostgreSQL servers
az postgres server list --resource-group myResourceGroup

# Delete a PostgreSQL server
az postgres server delete --resource-group myResourceGroup --name myServer

Explore all available commands by running: az postgres --help or visit the Azure CLI reference for PostgreSQL.

PowerShell Cmdlets

The Azure PowerShell module offers cmdlets for managing Azure Database for PostgreSQL.

Install the Azure PowerShell module by following instructions here.

Example cmdlets:

# Create a PostgreSQL server
New-AzPostgreSqlServer -ResourceGroupName "myResourceGroup" -Name "myServer" -Location "East US" -AdminLogin "myadmin" -AdminPassword "mypassword"

# Get PostgreSQL server details
Get-AzPostgreSqlServer -ResourceGroupName "myResourceGroup" -Name "myServer"

# Remove a PostgreSQL server
Remove-AzPostgreSqlServer -ResourceGroupName "myResourceGroup" -Name "myServer"

For a complete list of cmdlets and their parameters, refer to the Azure PowerShell PostgreSQL module documentation.

ARM Templates

Azure Resource Manager (ARM) templates allow you to define your infrastructure as code, enabling declarative deployment and management of Azure resources. You can use ARM templates to deploy Azure Database for PostgreSQL servers, databases, and related configurations.

You can find example ARM templates for Azure Database for PostgreSQL in the Azure Quickstart Templates repository.

Note: Using ARM templates promotes consistency and repeatability in your Azure deployments.