Deploy to Azure
This page takes you from nothing to a running dotMARC on Azure Container Apps, in order. Every value the deployment form asks for is explained in step 2, next to the button that opens it, so you don't need to jump between pages. Start with what you'll need, including an Azure subscription with billing set up.
What you'll need
- An Azure subscription with billing set up. dotMARC runs on paid Azure services (a Container App, a PostgreSQL Flexible Server, a Key Vault and a Log Analytics workspace), so the subscription needs a valid payment method or an invoiced agreement behind it. Check the cost for your region in the Azure pricing calculator before you deploy, and be aware that some free-trial, sponsorship and student subscriptions restrict which services or regions you can use.
- Permission to create resources and role assignments in that subscription: Owner on the resource group you deploy into is enough. Azure permissions and shell below explains the other permissions involved.
- A region that offers both Azure Container Apps and Azure Database for PostgreSQL Flexible Server.
- Microsoft Entra and Exchange Online access to create the two app registrations, an administrator who can grant them admin consent, and someone who can restrict the mailbox app to the DMARC reports mailbox in Exchange Online. These can be different people. The Microsoft Entra setup below covers each step.
- A shared mailbox to receive DMARC reports, in Microsoft 365 / Exchange Online.
- A way to run Azure CLI commands. Azure Cloud Shell needs nothing installed, or use PowerShell 7 with the Azure CLI on your own computer.
- About 30 minutes. Azure gives the app its own hostname. A custom domain is optional and can be added afterwards.
Microsoft Entra setup
dotMARC needs two separate Microsoft Entra app registrations. Do not reuse one for both purposes.
| Registration | Used for | You will need |
|---|---|---|
dotmarc-mailbox | Reading the DMARC reports mailbox (app-only Microsoft Graph) | Its client ID and a client secret |
dotmarc-dashboard | Signing people in to the dotMARC dashboard | Its client ID and a client secret |
Write down both client IDs, both client secrets and your tenant ID somewhere safe, because you enter them
when you configure dotMARC. The dashboard's redirect URI is https://<your-hostname>/signin-oidc. If you
don't know the hostname yet, add it to the dashboard registration after you deploy.
Create the apps with the script
Use the setup script, in PowerShell
or Bash, to create both
registrations and generate client secrets. Sign in to the intended tenant with Azure CLI first (az login). Use
its -Rbac / --rbac option, shown below: the mailbox app is then created without a Graph mail permission in Entra,
because you give it access in Exchange Online, limited to one mailbox, using the steps below. The script never grants
admin consent to the mailbox app.
You can run it in Azure Cloud Shell, or anywhere with the Azure CLI signed in. It creates app registrations and
secrets in your tenant, so download it and read it before you run it. It is short, and it only calls az.
Choose the version for your shell:
- PowerShell
- Bash
Download the script, then open it and check what it does:
Invoke-WebRequest https://raw.githubusercontent.com/homotechsual/dotMARC/main/scripts/entra/create-dotmarc-apps.ps1 -OutFile create-dotmarc-apps.ps1
When you are happy with it, unblock it and run it:
Unblock-File ./create-dotmarc-apps.ps1
./create-dotmarc-apps.ps1 -Rbac -DashboardRedirectUri https://dotmarc.example.com/signin-oidc
Unblock-File removes the "downloaded from the internet" mark that Windows puts on files saved from a browser, which
PowerShell's default RemoteSigned policy would otherwise refuse to run. Only run it once you have read the script. If
PowerShell still says running scripts is disabled, allow it for this window only with
Set-ExecutionPolicy -Scope Process RemoteSigned.
If you don't know the hostname yet (Azure Container Apps assigns it during deployment), leave out
-DashboardRedirectUri and add the deployed URL ending in /signin-oidc to the dashboard app after
deployment. Add -IncludeMailSend if you plan to send client reports through
Microsoft Graph. Leave out -Rbac only if you are using an Application Access Policy (see the legacy section below).
Download the script, then open it and check what it does:
curl -fsSLO https://raw.githubusercontent.com/homotechsual/dotMARC/main/scripts/entra/create-dotmarc-apps.sh
When you are happy with it, run it:
bash create-dotmarc-apps.sh --rbac --dashboard-redirect-uri https://dotmarc.example.com/signin-oidc
If you don't know the hostname yet (Azure Container Apps assigns it during deployment), omit
--dashboard-redirect-uri and add the deployed URL ending in /signin-oidc to the dashboard app
after deployment. Add --include-mail-send if you plan to send client reports
through Microsoft Graph. Leave out --rbac only if you are using an Application Access Policy (see the legacy section below).
Either script prints your tenant ID, the two client IDs and the newly-created secrets; copy the secrets when shown. With the RBAC option it also prints the mailbox app's service principal object ID and the Exchange role to assign. Each run creates additional secrets for the reused app registrations.
Mailbox app registration (app-only)
- If setting up manually, App registrations → New registration, name it e.g.
dotmarc-mailbox. - If setting up manually, Certificates & secrets → create a client secret.
- Give the app access to the mailbox inside Exchange Online, limited to the DMARC reports mailbox, using
RBAC for Applications as described below. Do not add the Microsoft Graph
Mail.ReadWritepermission in Entra and grant it admin consent: a consent granted in Entra applies to every mailbox in your tenant, and it adds to the Exchange grant instead of being limited by it.
The setup script's -Rbac (PowerShell) or --rbac (Bash) option does the Entra side of this for you. It creates the
app without a Graph mail permission, creates the app's service principal, and prints the two IDs and the Exchange role
you need in the next section.
Why RBAC for Applications and not an Application Access Policy
Microsoft has replaced Application Access Policies with RBAC for Applications in Exchange Online and says new setups shouldn't use access policies, because they will eventually need migrating. If you already have a policy in place, it keeps working, and the section at the end of this page covers it and how to move off it.
Limit the app to the DMARC reports mailbox
These commands come from the ExchangeOnlineManagement PowerShell module (PowerShell Gallery, Microsoft Learn). Check you have that module, and not an older Exchange module, by installing or updating it first. A normal window is enough (an administrator window is only needed for an all-users install):
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
You need to be a member of the Organization Management role group in Exchange Online, and to hold the Exchange Administrator role in Microsoft Entra, to assign these permissions. Microsoft's RBAC for Applications article covers the detail. Then run the commands below, replacing the values in angle brackets:
# Connect-ExchangeOnline and the cmdlets after it are from the ExchangeOnlineManagement module.
Connect-ExchangeOnline -Organization <your-tenant>
# 1. A mail-enabled security group that holds only the mailbox(es) dotMARC may use.
$group = New-DistributionGroup -Name "dotMARC DMARC Reports Scope" -Type Security -Alias dotmarc-dmarc-reports
# 2. A management scope covering the members of that group.
$groupDn = (Get-Group -Identity $group.Identity).DistinguishedName
New-ManagementScope -Name "dotMARC mailboxes" -RecipientRestrictionFilter "MemberOfGroup -eq '$groupDn'"
# 3. Tell Exchange about the mailbox app. Use the IDs the setup script printed, or the ones on the app's page under
# Enterprise applications in Entra. The IDs on the App registrations page are different, don't use those.
New-ServicePrincipal -AppId <client-id> -ObjectId <service-principal-object-id> -DisplayName "dotMARC mailbox"
Then give the app a role, limited to that scope. Choose one of these:
- Mail.ReadWrite (read only)
- Mail Full Access (read and send)
The app can read the mailbox and mark reports as read, and nothing else. This is all dotMARC needs to collect reports. You can add sending later (see the next tab).
# 4. Let the app read mail and mark it as read, but only in that scope.
New-ManagementRoleAssignment -App <service-principal-object-id> -Role "Application Mail.ReadWrite" -CustomResourceScope "dotMARC mailboxes"
To send client reports through Microsoft Graph later, add Application Mail.Send for the same app
and scope with a second assignment:
New-ManagementRoleAssignment -App <service-principal-object-id> -Role "Application Mail.Send" -CustomResourceScope "dotMARC mailboxes"
One role that covers reading, marking as read and sending, so client reports can be sent through
Microsoft Graph from the same mailboxes. Use it instead of Application Mail.ReadWrite, not as well.
# 4. Let the app read, mark as read and send mail, but only in that scope.
New-ManagementRoleAssignment -App <service-principal-object-id> -Role "Application Mail Full Access" -CustomResourceScope "dotMARC mailboxes"
Then check it. InScope should be True for the DMARC reports mailbox:
# 5. Check it.
Test-ServicePrincipalAuthorization -Identity <client-id> -Resource dmarc-reports@example.uk
If you already have a mail-enabled security group for this, use it in step 2 in place of the new one. Three things to know:
- Only direct members count. A mailbox that is a member of a group nested inside this one is out of scope.
- Changes take time. Microsoft says a change to an app's permissions can take between 30 minutes and 2 hours to
apply, depending on how recently the app was used. The test command in step 5 ignores that delay, so it can say
Truebefore dotMARC can actually read the mailbox. - Sending client reports needs a send role.
Application Mail.ReadWritealone can't send, so choose the Full Access tab in step 4, or addApplication Mail.Sendas a second assignment.
Finally, make sure the app has no Microsoft Graph mail permission granted in Entra: in the Entra admin center, open
the app under Enterprise applications, then Permissions, and check nothing for Mail.* is listed as granted.
If something is, remove it, or the app keeps access to every mailbox and the Exchange scope achieves nothing.
Already using an Application Access Policy?
An Application Access Policy still works, but Microsoft treats it as a legacy feature. It limits a permission you
have granted in Entra (the Microsoft Graph application permission Mail.ReadWrite, with admin consent), instead of
granting access in Exchange. Exchange requires the policy scope to be a security principal (for example a
mail-enabled security group), not the mailbox itself. Create a dedicated group for the DMARC reports mailbox, add that
mailbox to the group, and then scope the policy to the group. Add the Graph application permission and grant admin
consent only after the policy exists:
# From the ExchangeOnlineManagement module, as above.
Connect-ExchangeOnline -Organization <your-tenant>
$group = New-DistributionGroup -Name "dotMARC DMARC Reports Scope" -Type Security -Alias dotmarc-dmarc-reports
New-ApplicationAccessPolicy -AppId <client-id> -PolicyScopeGroupId $group.ObjectId -AccessRight RestrictAccess -Description "dotMARC: restrict to DMARC reports mailbox only"
If you already have the mail-enabled security group, use its ObjectId instead of the mailbox address. Do not pass
the mailbox address directly to -PolicyScopeGroupId. After creating the policy, grant admin consent in API
permissions (or run the az ad app permission admin-consent --id <mailbox-client-id> command the setup script prints
when you don't use -Rbac). Microsoft's
Application Access Policies
article covers the policy itself. If permissions are missing, the dashboard's poll status says which, with a link to
grant admin consent.
Moving an existing install to RBAC for Applications. Microsoft's guidance for reusing the policy's group lets you move over without interrupting dotMARC:
- Create a management scope that points at the policy's group (step 2 above, with that group).
- Create the service principal pointer (step 3 above).
- Assign the role with that scope (step 4 above).
- Run the test (step 5 above) and let the change take effect, which can take up to two hours.
- Remove the Microsoft Graph mail permission's consent in Entra (Enterprise applications, then Permissions).
- Remove the Application Access Policy (
Remove-ApplicationAccessPolicy).
Dashboard app registration (delegated sign-in)
- If setting up manually, App registrations → New registration, name it e.g.
dotmarc-dashboard. - Add an Authentication → Web platform redirect URI:
https://<your-deployment-host>/signin-oidc. On the same page, under Implicit grant and hybrid flows, check ID tokens - Microsoft.Identity.Web's OIDC middleware requests anid_tokenas part of its hybrid authorization-code flow, and without this box checked sign-in fails at the Entra consent step (the redirect back to/signin-oidcnever happens). - If setting up manually, Certificates & secrets → create a client secret. Microsoft.Identity.Web wires this app up via the standard confidential-client authorization-code flow, so the token exchange after sign-in needs this secret even though the app itself is only used for interactive sign-in.
- No API permissions are needed beyond delegated
User.Read(added by the script; it is also the default when registering an app in the portal). - If your tenant only lets administrators approve apps, open API permissions and select Grant admin consent.
Without it, people can't sign in: dotMARC shows "An administrator needs to approve dotMARC" with a link an Entra
administrator can use to approve it (error
AADSTS65001orconsent_required).
Azure assigns the app's hostname during deployment, so you add the dashboard's redirect URI afterwards, in step 4. The client IDs go into the deployment form in step 2 and the client secrets go into Key Vault in step 5.
Azure permissions and shell
Check your Azure permissions
Two different things need permission, and they are easy to mix up:
| Who | What they need | Why |
|---|---|---|
| You, to deploy | Owner on the resource group (or Contributor plus User Access Administrator) | The template creates resources and role assignments |
| You, to fill Key Vault | Key Vault Secrets Officer on the new vault, which you grant yourself in step 5 | Owner does not include permission to write secrets. Without it Azure answers Forbidden for Microsoft.KeyVault/vaults/secrets/setSecret/action |
| The Container App's managed identity | Key Vault Secrets User on the vault | Lets the app read its secrets. The template grants this for you |
Use PowerShell
The commands on this page are PowerShell, including the app registration script above (which also has a Bash version if you prefer it). In Azure Cloud Shell, switch the shell type from Bash to PowerShell using the dropdown at the top left of the Cloud Shell window before you run the commands below. On your own computer (Windows, macOS or Linux), use PowerShell 7 with the Azure CLI installed.
Anything written like <this> is specific to you and must be replaced. Every other name in the
commands (the resource group variable aside) is found for you by the commands themselves, so you don't
need to know the deployment name, the Key Vault name or the Container App name in advance.
1. Choose the subscription and resource group
Azure Cloud Shell and the Azure CLI each have a current subscription, and it is often not the one you intend to deploy into. Resources in another subscription are invisible, which looks like "not found". Check which one is selected, and select the right one:
az account list --query "[].{Name:name,Id:id,Selected:isDefault}" --output table
az account set --subscription '<subscription-id>'
az account show --query "{Name:name,Id:id}" --output table
Pick a new resource group name and a region that supports Container Apps and PostgreSQL Flexible
Server (for example uksouth). The portal form creates the group for you; for the CLI, create it now:
$RG = '<your-resource-group>'
az group create --name $RG --location uksouth
Remember the name you chose, you will use it in every later step.
2. Deploy
Fill in the deployment form
Whether you use the portal button or the command line, these are the values to supply. Each row says where to find the value and which app registration it belongs to.
| Field | What to enter | Where to find it |
|---|---|---|
graphClientId | The mailbox app registration's Application (client) ID, a GUID | Microsoft Entra, App registrations, dotmarc-mailbox, Overview |
graphTenantId | Your tenant (directory) ID, a GUID | Same Overview page, Directory (tenant) ID |
graphMailboxAddress | The shared mailbox receiving DMARC reports, such as [email protected] | Your Exchange Online mailbox |
graphTlsrptMailboxAddress | Optional separate mailbox for TLS reports. Leave blank to use the one above | Your Exchange Online mailbox |
entraIdTenantId | Your tenant ID again, a GUID. Normally the same value as graphTenantId | Same Overview page |
entraIdClientId | The dashboard app registration's Application (client) ID, a GUID. Not the mailbox one | Microsoft Entra, App registrations, dotmarc-dashboard, Overview |
initialAdminEmails | Required. Comma-separated email addresses of the people who should be Admins, such as [email protected] | Your own sign-in email |
postgresAdminPassword | A new strong password for the database. Note it down, step 5 needs it | You choose it |
postgresAdminUsername | Database administrator name. The default dotmarc is fine | Leave as is |
containerImage | The image to run. Use ghcr.io/homotechsual/dotmarc:latest or a release tag | Leave as is |
Without it nobody can sign in to a fresh installation, so the form won't submit with it empty. Use the same email address you will sign in with. The setting only takes effect on the very first start, but the form asks for it every time, including when you redeploy over an existing deployment. The portal fills in most fields from the previous deployment but not this one, so check it before you deploy.
The client secrets are deliberately not part of the form. They would end up in deployment history, so you put them in Key Vault yourself in step 5.
Deploy with the portal button
Sign in to the Azure portal with the same account and subscription you chose in step 1, then:
Choose the subscription, the resource group you created (or create a new one), a region, then fill in
the fields from the table above. The portal names the deployment CustomDeployment-<something>, not
main. You don't need to remember it, step 3 finds it for you.
Or deploy with the command line
Copy infra/main.parameters.json and replace the REPLACE_ME placeholders using the table above. As
checked in the file contains placeholders only and is not meant to be deployed as is. Then, with
$RG set as in step 1:
az deployment group create `
--resource-group $RG `
--name main `
--template-file infra/main.bicep `
--parameters infra/main.parameters.json
You can pass single values inline instead of editing the file, for example
--parameters postgresAdminPassword='<password>'.
Where the portal's template comes from, and building it yourself
The portal uses dotmarc.app/azuredeploy.json, compiled from
infra/main.bicep during every website build. Bicep is the source of truth; the generated JSON is not
checked in. Local website builds need the same Bicep compiler as CI (no Azure sign-in needed):
az bicep install --version v0.46.1
cd website
yarn gen-azure-template
What gets created
-
A Container Apps environment (backed by a Log Analytics workspace) and a Container App running the published dotMARC image, with a system-assigned managed identity, sticky sessions (required for Blazor Server), and a single replica.
-
An Azure Database for PostgreSQL Flexible Server (
Standard_B1ms, PostgreSQL 18) with adotmarcdatabase and a firewall rule allowing Azure services. -
A Key Vault (RBAC-authorized), with the Container App's managed identity granted the
Key Vault Secrets Userrole. -
Optionally (
enableMtaStsHosting), two narrowly-scoped custom RBAC roles letting the Container App manage its own custom domains and managed certificates, for MTA-STS policy hosting. Exact permissions:Role Scope Actions Container App role the Container App itself containerApps/read,containerApps/writeManaged Environment role the Container Apps environment managedEnvironments/read,managedEnvironments/join/action,managedEnvironments/managedCertificates/read,managedEnvironments/managedCertificates/writemanagedEnvironments/join/actionis easy to leave out and easy to miss when you do: Azure requires it on any update to the Container App's ingress/custom-domain config, not just when first attaching the app to the environment, and its own error (LinkedAuthorizationFailed/403) reads like a Container-App-scoped permission problem rather than pointing at the environment-scoped role that's actually missing it.
The button provisions infrastructure only. The app cannot start properly until you complete steps 4 and 5: register the redirect URI and put the secrets in Key Vault. Until then the site may show a timeout. That is expected.
3. Find the resources this deployment created
You may not know your deployment's name (the portal calls it CustomDeployment-<something>), and you
don't need it. This finds everything by looking at what is in the resource group, and stops with a
clear message if anything is missing. Run it in the same PowerShell session as the later steps, with
$RG set to your resource group:
function Get-Required($What, $Value) {
if (-not $Value) {
throw "Couldn't find $What in resource group '$RG'. Check the subscription (step 1) and that the deployment finished: az deployment group list --resource-group '$RG' --query ""[].{Name:name,State:properties.provisioningState}"" -o table"
}
$Value
}
$KV = Get-Required 'the Key Vault' (az keyvault list --resource-group $RG --query "[0].name" -o tsv)
$KV_ID = Get-Required 'the Key Vault id' (az keyvault show --name $KV --resource-group $RG --query id -o tsv)
$APP = Get-Required 'the Container App' (az containerapp list --resource-group $RG --query "[0].name" -o tsv)
$PG_FQDN = Get-Required 'the PostgreSQL server' (az postgres flexible-server list --resource-group $RG --query "[0].fullyQualifiedDomainName" -o tsv)
$APP_URL = Get-Required 'the Container App URL' ('https://' + (az containerapp show --resource-group $RG --name $APP --query properties.configuration.ingress.fqdn -o tsv))
"Key Vault: $KV`nContainer App: $APP`nPostgreSQL: $PG_FQDN`nURL: $APP_URL"
If you would rather use the deployment itself, the same values are on its Outputs tab in the portal.
4. Register the deployed hostname as an OIDC redirect URI
If you're configuring a custom domain in the Azure Portal for your container app your OIDC redirect URI should be https://<yourcustomURL>/signin-oidc
The Container App's hostname isn't known until after deployment (Container Apps assigns its FQDN from the environment's own DNS suffix), so the redirect URI in the dashboard sign-in app registration can't be filled in ahead of time. Print the value to add:
"$APP_URL/signin-oidc"
Then, in the dotmarc-dashboard app registration's Authentication blade, add a Web
platform redirect URI of that value (alongside or replacing the placeholder one added during
one-time setup). Sign-in will fail with AADSTS50011 until this is done.
5. Populate Key Vault
The template deliberately provisions three Key Vault secrets (Graph-ClientSecret,
EntraId-ClientSecret and ConnectionStrings-DotMarc) with empty values, rather than accepting secret
material as deployment parameters (which would put it on the command line or in a parameters
file). Until they are set, the app can't sign in or reach Postgres.
There are four parts: give yourself permission, write the secrets, re-apply the Container App's references to them, then restart. Do all four. Writing the secrets and restarting alone is not enough, see the note after the script.
5a. Give yourself permission to write secrets
Owner on the resource group does not include permission to write Key Vault secrets. Grant yourself Key Vault Secrets Officer on the vault:
$ME = az ad signed-in-user show --query id -o tsv
az role assignment create `
--assignee-object-id $ME `
--assignee-principal-type User `
--role "Key Vault Secrets Officer" `
--scope $KV_ID
Azure can take a few minutes to apply the new role. If the next command answers Forbidden, wait two
or three minutes and run it again.
5b. Write the three secrets
Substitute the dotmarc-mailbox and dotmarc-dashboard client secrets you created during setup, and
the database user name and password from the form:
az keyvault secret set --vault-name $KV --name Graph-ClientSecret --value '<mailbox app client secret>'
az keyvault secret set --vault-name $KV --name EntraId-ClientSecret --value '<dashboard app client secret>'
az keyvault secret set --vault-name $KV --name ConnectionStrings-DotMarc `
--value "Host=$PG_FQDN;Database=dotmarc;Username=<postgresAdminUsername>;Password=<postgresAdminPassword>;Ssl Mode=Require"
Use single quotes around the client secrets so PowerShell doesn't treat characters such as $ in them
specially.
5c. Re-apply the secret references and restart
In practice the Container App resolves its Key Vault references when the revision is created, which happens before you
have written them. Setting new values in Key Vault does not make a running revision pick them up,
and restarting it doesn't either. Re-apply all three references together (Azure validates the whole
configuration, so setting one on its own fails with SecretRef 'entraid-client-secret' ... not found),
then restart:
$VAULT = "https://$KV.vault.azure.net/secrets"
az containerapp secret set `
--resource-group $RG `
--name $APP `
--secrets `
"graph-client-secret=keyvaultref:$VAULT/Graph-ClientSecret,identityref:system" `
"entraid-client-secret=keyvaultref:$VAULT/EntraId-ClientSecret,identityref:system" `
"connectionstrings-dotmarc=keyvaultref:$VAULT/ConnectionStrings-DotMarc,identityref:system"
$REVISION = az containerapp show --resource-group $RG --name $APP --query properties.latestRevisionName -o tsv
az containerapp revision restart --resource-group $RG --name $APP --revision $REVISION
Without this step a new deployment can sit with the revision in Activating, with no replicas
running and a browser stream timeout. The system log then shows KEDAScalerFailed ... error resolving secret name graph-client-secret, even though the secrets exist and the managed identity has the right
role. See Troubleshooting. Use the same re-apply command whenever you replace a secret value in
Key Vault later (for example when a client secret expires).
Set InitialAdmins__Emails (the initialAdminEmails form field, see Getting Started) before this
deployment's first startup. Without it the tightened authorization policy locks out every user,
including you.
How the three layers of names line up
The same secret has a different name at each layer. Don't rename the Key Vault secrets to match the environment variables:
| Layer | Graph secret | Dashboard secret | Database connection |
|---|---|---|---|
| Key Vault secret (single hyphen) | Graph-ClientSecret | EntraId-ClientSecret | ConnectionStrings-DotMarc |
| Container App secret reference (lowercase) | graph-client-secret | entraid-client-secret | connectionstrings-dotmarc |
| Environment variable in the app (double underscore) | Graph__ClientSecret | EntraId__ClientSecret | ConnectionStrings__DotMarc |
The double underscore maps to ASP.NET Core's configuration hierarchy and only applies to the environment variable. Key Vault secret names can't contain underscores.
6. Check it's healthy
Don't treat the deployment as complete until the active revision reports Healthy and Running:
az containerapp revision list `
--resource-group $RG `
--name $APP `
--query "[].{Revision:name,Active:properties.active,Health:properties.healthState,Running:properties.runningState,Replicas:properties.replicas}" `
--output table
A healthy revision shows Healthy and Running (or RunningAtMaxScale, which just means it is at the
configured replica count). It can take a minute or two after the restart. Then open $APP_URL, sign in,
and check Poll status for a successful first cycle.
Troubleshooting
The site shows stream timeout, or the revision stays on Activating with health None. The
container never started. Console logs don't exist yet (az containerapp logs show answers Could not find container), so read the system log:
az containerapp logs show --resource-group $RG --name $APP --type system --tail 50 --follow false
KEDAScalerFailedorerror resolving secret name ...: the Key Vault secret references didn't resolve. Do step 5c again (all three references, then restart). If it still fails, check the Container App's identity really hasKey Vault Secrets Useron the vault (Access control (IAM) on the Key Vault, then Role assignments) and that all three secrets are enabled and not empty.ContainerAppSecretRefNotFound: you set one reference on its own. Set all three together, as in step 5c.
Forbidden ... setSecret/action when writing a secret. You don't have Key Vault Secrets
Officer yet. Do step 5a and wait a few minutes.
DeploymentNotFound or an empty value from one of the discovery commands. Wrong subscription or
resource group. Repeat step 1. To see what is deployed
in the group you chose:
az deployment group list --resource-group $RG --query "[].{Name:name,State:properties.provisioningState}" --output table
argument --vault-name: expected one argument. $KV is empty because step 3 found nothing. Fix the
subscription or resource group and run step 3 again.
Optional: Key Vault-backed secret storage
By default, runtime-editable secrets (the HaloPSA API client secret, Cloudflare/Azure DNS push
OAuth client secrets - anything configured through an in-app settings page rather than a deployment
parameter) are encrypted and stored in Postgres. To store them in this deployment's Key Vault
instead, redeploy with enableKeyVaultWrite set to true - this grants the container app's
managed identity a narrowly-scoped write role on the vault (see infra/main.bicep's
keyVaultWriteRole, it adds only secrets/setSecret, read is already covered by the existing
Key Vault Secrets User assignment). No manual az keyvault secret set needed here, the app
writes each secret itself the first time you save it from the relevant settings page.
7. Update or redeploy dotMARC
This is the Azure part of Update or redeploy dotMARC, which also covers what to check before and after an update.
Enter your details to get the variables the commands on this page use. Nothing is sent anywhere, and the resource group and subscription are remembered in this browser.
Your details
Run this first in PowerShell. Every command below uses these variables. The Container App is found from the resource group, so you don't need its name or the deployment name.
$RG = '<your-resource-group>'
$APP = az containerapp list --resource-group $RG --query "[0].name" -o tsv
if (-not $APP) { throw "No Container App found in resource group '$RG'. Check the subscription and resource group." }
$VERSION = '0.10.3'
Container Apps stores the image reference in a revision. Check the image configured on the currently active app, then list its revision history:
az containerapp show `
--resource-group $RG `
--name $APP `
--query "properties.template.containers[0].image" `
--output tsv
az containerapp revision list `
--resource-group $RG `
--name $APP `
--query "[].{Revision:name,Active:properties.active,Created:properties.createdTime,Image:properties.template.containers[0].image}" `
--output table
What version is actually running?
For an immutable release reference such as ghcr.io/homotechsual/dotmarc:0.10.3, the tag identifies
the version. If the configured image is :latest, Azure only reports :latest - that mutable tag
does not reveal which build was pulled. Check the version shown in dotMARC's footer, or compare the
deployment time with the image published by the relevant release. Prefer release tags for
production so the deployed version and rollback target are unambiguous.
Update to a specific release (recommended)
Use an immutable release tag. az containerapp update creates a new revision and, because this
template uses single-revision mode, moves traffic to it after it becomes ready:
$IMAGE = "ghcr.io/homotechsual/dotmarc:$VERSION"
$REVISION_SUFFIX = "release-$(Get-Date -Format yyyyMMddHHmmss)"
az containerapp update `
--resource-group $RG `
--name $APP `
--image $IMAGE `
--revision-suffix $REVISION_SUFFIX
The app runs EF Core migrations during startup. Do not run a separate migration command; wait for the new revision to become ready before considering the update complete.
Redeploy when the app is configured with :latest
Publishing a new image under :latest does not automatically update a running Container App.
Running az containerapp revision restart only restarts the existing revision; use it for refreshed
Key Vault references or a stuck replica, not as the image-update mechanism.
If the configured image string remains exactly the same, force a new revision by supplying a unique revision suffix:
$IMAGE = 'ghcr.io/homotechsual/dotmarc:latest'
$REVISION_SUFFIX = "latest-$(Get-Date -Format yyyyMMddHHmmss)"
az containerapp update `
--resource-group $RG `
--name $APP `
--image $IMAGE `
--revision-suffix $REVISION_SUFFIX
The unique suffix makes this a new revision even though the image reference is still :latest, so
Container Apps resolves and pulls the tag again. This is inherently less auditable than deploying
a release tag: the revision records :latest, not the release version it represented at that time.
Update through Bicep
If the deployment is intentionally managed through infra/main.bicep, set containerImage to the
new immutable release tag, run the --what-if check in the next section, then apply the template.
A Bicep redeploy with containerImage still set to the same :latest string may show no template
change and therefore may not create a new revision. In that case, either change to a release tag or
use the forced-revision command above.
Verify the update
$REVISION = az containerapp show `
--resource-group $RG `
--name $APP `
--query properties.latestReadyRevisionName `
--output tsv
az containerapp revision show `
--resource-group $RG `
--name $APP `
--revision $REVISION `
--query "{Revision:name,Active:properties.active,Image:properties.template.containers[0].image,Replicas:properties.replicas}" `
--output table
az containerapp logs show `
--resource-group $RG `
--name $APP `
--revision $REVISION `
--tail 100
Then load the dashboard, confirm the expected version in its footer, sign in, and check Poll status for a successful post-deployment cycle.
Roll back
Create another revision using the previous immutable release tag. Fill in Version to roll back to in your
details above so $PREVIOUS_VERSION is set:
$IMAGE = "ghcr.io/homotechsual/dotmarc:$PREVIOUS_VERSION"
$REVISION_SUFFIX = "rollback-$(Get-Date -Format yyyyMMddHHmmss)"
az containerapp update `
--resource-group $RG `
--name $APP `
--image $IMAGE `
--revision-suffix $REVISION_SUFFIX
Do not roll back blindly after a release that applied database migrations: application rollback is
only safe when the older release remains compatible with the current schema. A deployment that
only ever recorded :latest also has no reliable historical image target; choose the previous
release tag explicitly.
8. Re-running the template later (e.g. to turn on MTA-STS hosting)
enableMtaStsHosting is off by default, so enabling it (or making any other change) usually means
re-running az deployment group create against a resource group that's no longer in exactly the
state the template describes: you've likely since bound a custom domain to the Container App
(through the Portal, or az containerapp hostname add), and Azure may have changed Postgres
storage/tier/Entra-auth settings that aren't declared in main.bicep at all. ARM deployments only
touch what's declared, but for a property Bicep explicitly declares as a whole object (this
template's ingress block, or flexibleServers' storage/authConfig), a redeploy replaces that
whole object with what the template says, silently dropping anything set outside it.
Always run --what-if before the real deployment once a resource group has any post-deploy
customization:
az deployment group what-if `
--resource-group $RG `
--template-file infra/main.bicep `
--parameters infra/main.parameters.json
If the what-if diff shows changes you don't want, apply just the one change by hand
Read the diff carefully. A ~ Microsoft.App/containerApps/<name> entry removing
properties.configuration.ingress.customDomains, or a ~ Microsoft.DBforPostgreSQL/flexibleServers/<name>
entry removing storage/authConfig properties, means applying it would break your custom domain
or reset database settings you configured after the original deployment. Don't proceed if you see
that; either update the template's parameters/resources to match current state first, or apply just
the specific change you actually need by hand instead of the whole template:
# The two custom roles enableMtaStsHosting would have created, applied directly instead of via
# a full template redeploy. See the roleDefinition resources in main.bicep for the exact
# actions/description each one needs.
az role definition create --role-definition <role JSON, one per role>
az role assignment create --assignee-object-id <container app's principalId> `
--assignee-principal-type ServicePrincipal --role <role id> --scope <container app or environment resource id>
# The env vars enableMtaStsHosting's parameters would have set, merged onto the existing
# container without touching anything else (existing env vars are left alone):
az containerapp update --name $APP --resource-group $RG --set-env-vars `
"MtaSts__HostingHostname=<container app FQDN>" "MtaSts__Provisioner=Azure" `
"MtaSts__AzureSubscriptionId=<subscription id>" "MtaSts__AzureResourceGroupName=$RG" `
"MtaSts__AzureContainerAppName=$APP" "MtaSts__AzureManagedEnvironmentName=<environment name>"
If you're running these az commands from Git Bash on Windows rather than PowerShell, any
argument starting with / (every Azure resource ID) gets silently mangled into a Windows path by
MSYS's path conversion, MissingSubscription errors on az role assignment create are the
usual symptom. Set export MSYS_NO_PATHCONV=1 first.
Want to host MTA-STS policies for customer domains? See MTA-STS: hosting infrastructure
for the one-time enableMtaStsHosting setup - each domain you later enable also needs an extra
domain-ownership TXT record Container Apps requires that a self-hosted deployment doesn't, covered
in MTA-STS: enabling a domain.