Skip to content

Database

One DjangoDeployment creates a single Azure Database for PostgreSQL Flexible Server (Entra ID authentication only; password auth disabled). Multiple Django apps on that deployment each get their own database via db_name.

Defaults include 32 GB storage with auto-grow and 7-day backup retention.

Deployment parameters

pgsql_sku

pgsql_sku=azure.dbforpostgresql.SkuArgs(
    name="Standard_B1ms",
    tier=azure.dbforpostgresql.SkuTier.BURSTABLE,
)

pgsql_ip_prefix

Subnet prefix for the Postgres delegated subnet (typically /24).

pgsql_version

Defaults to "17".

pgsql_parameters

Optional server configuration key/value map.

pgadmin_access_ip

IP allowlist for pgAdmin. Empty means open (still password-protected).

Per-website database

django.add_django_website(
    name="prod",
    db_name="prod",
    # ...
)

Exports:

  • {name}_site_db_user — e.g. prod_managed_identity
  • {name}_site_principal_id — managed identity object ID
  • pgsql_host — server FQDN

Entra principal for the Web App (manual)

Postgres does not auto-create the app’s AAD principal. As an Entra admin on the server, run on the postgres database:

SELECT * FROM pgaadauth_create_principal_with_oid(
  'prod_managed_identity',
  'c8b25b85-d060-4cfc-bad4-b8581cfdf946',
  'service',
  false,
  false
);

Use the role name from {name}_site_db_user and the GUID from {name}_site_principal_id. Grant connect/privileges on the app database.

Microsoft docs: Create a role using Microsoft Entra object identifier.

Administrator login

django.add_database_administrator(
    object_id="b306adf5-fc61-4a32-8156-ce032dc1571f",
    user_name="you@example.com",
)

Temporary password/token:

az account get-access-token --resource-type oss-rdbms

Use your email as the username and the token as the password (pgAdmin or psql).

pgAdmin

Created on the shared App Service plan. Export: pgadmin_url.

Default credentials (change immediately):

  • Login: dbadmin@dbadmin.net
  • Password: dbadmin

Create your own user and remove the default.