Pulumi stack¶
Install the package in your Pulumi project, then define a stack similar to the sample below.
Important
Always import from the submodule:
Do not use from pulumi_django_azure import DjangoDeployment — the package root does not re-export these types (so Pulumi-only projects do not pull Django settings by accident).
Sample stack¶
import pulumi
import pulumi_azure_native as azure
from pulumi_django_azure.django_deployment import DjangoDeployment, HostDefinition
stack = pulumi.get_stack()
rg = azure.resources.ResourceGroup(f"rg-{stack}")
vnet = azure.network.VirtualNetwork(
f"vnet-{stack}",
resource_group_name=rg.name,
address_space=azure.network.AddressSpaceArgs(
address_prefixes=["10.0.0.0/16"],
),
)
django = DjangoDeployment(
stack,
tenant_id="00000000-0000-0000-0000-000000000000", # Entra tenant
resource_group_name=rg.name,
vnet=vnet,
pgsql_sku=azure.dbforpostgresql.SkuArgs(
name="Standard_B1ms",
tier=azure.dbforpostgresql.SkuTier.BURSTABLE,
),
pgsql_ip_prefix="10.0.10.0/24",
app_service_ip_prefix="10.0.20.0/24",
app_service_sku=azure.web.SkuDescriptionArgs(
name="B2",
tier="Basic",
),
storage_account_name="mystorageaccount", # globally unique
cdn_host="cdn.example.com", # optional str; omit or None for default AFD hostname
)
django.add_django_website(
name="web",
db_name="mywebsite",
repository_url="git@gitlab.com:project/website.git",
repository_branch="main",
website_hosts=[
HostDefinition("example.com", aliases=["www.example.com"]),
],
django_settings_module="mywebsite.settings.production",
environment_variables={}, # pass {} if you have no extras (do not pass None)
secrets={},
comms_data_location="europe",
comms_domains=["example.com"],
)
django.add_database_administrator(
object_id="00000000-0000-0000-0000-000000000000",
user_name="you@example.com",
)
Parameter notes¶
| Parameter | Notes |
|---|---|
app_service_ip_prefix |
Subnet for App Service (not appservice_ip_prefix). |
cdn_host |
Optional str, not a HostDefinition. |
website_hosts |
list[HostDefinition]. Constructor is HostDefinition(host, aliases=None). identifier is a derived property (example.com → example-com). |
environment_variables / secrets |
Prefer empty dicts over None — the implementation mutates these mappings. |
add_database_administrator |
Takes object_id and user_name only; tenant comes from the deployment. |
Full API: DjangoDeployment reference.
After first pulumi up¶
- Create DNS from stack outputs (Domains and HTTPS).
- Create the Entra DB principal for
{name}_managed_identity(Database). - Wire Git deploy SSH key / webhook from
{name}_deploy_ssh_key_urland{name}_deploy_url.