Skip to content

Run Cratis Chronicle on Azure with Microsoft Entra ID

Run the Cratis Chronicle kernel on Azure with Microsoft Entra ID to connect to Azure SQL or Azure Database for PostgreSQL without database passwords. Start with the storage configuration for your database, then add an HTTP connection resolver if your platform places tenants in separate databases.

The later sections cover health probes, authenticated webhooks and multi-node availability. The combined environment-variable example gives you a starting configuration for Azure Container Apps or Azure Kubernetes Service (AKS); each section links to its full configuration reference.

  • The cratis/chronicle image. Its SQL Server support includes Microsoft.Data.SqlClient.Extensions.Azure, which provides the Entra authentication modes, and its HTTP connection resolver can authenticate with Entra ID.
  • A user-assigned managed identity for the kernel. On AKS, use workload identity bound to an Entra application instead.
  • An Azure SQL database or an Azure Database for PostgreSQL server that the identity can reach.

Use one identity for the kernel and grant it only what each step below needs. Its clientId is what you put in connection strings and resolver settings. A system-assigned identity also works where a step says so.

Create a database user for the identity with CREATE USER [chronicle-kernel] FROM EXTERNAL PROVIDER, and grant it the permissions to read and write data and, because Chronicle creates and migrates its own tables, to create and alter them. To split those permissions, resolve a schema identity and a runtime identity separately by purpose. Then point connectionDetails at the database with an Entra mode instead of a password:

Terminal window
Cratis__Chronicle__Storage__Type=MsSql
Cratis__Chronicle__Storage__ConnectionDetails='Server=myserver.database.windows.net;Database=chronicle;Authentication=Active Directory Managed Identity;User Id=<managed-identity-client-id>;Encrypt=true'

The kernel supports every Entra mode of the Authentication keyword, so Active Directory Workload Identity is the choice on AKS, where the workload identity webhook injects AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE. The modes, and what you must not combine with a resolved token, are listed under Microsoft Entra ID authentication.

Store events in Azure Database for PostgreSQL

Section titled “Store events in Azure Database for PostgreSQL”

PostgreSQL has no Authentication= mode in the connection string. Enable native Entra authentication and give the PostgreSQL name of the identity as Username. Provision that identity in Azure Database for PostgreSQL and grant it the permissions to read, write and migrate Chronicle’s tables, as for Azure SQL above.

Terminal window
Cratis__Chronicle__Storage__Type=PostgreSql
Cratis__Chronicle__Storage__ConnectionDetails='Host=myserver.postgres.database.azure.com;Database=chronicle;Username=chronicle-kernel;SSL Mode=VerifyFull'
Cratis__Chronicle__Storage__PostgreSqlEntra__Enabled=true
Cratis__Chronicle__Storage__PostgreSqlEntra__ManagedIdentityClientId='<managed-identity-client-id>'

Chronicle uses DefaultAzureCredential to request a token for https://ossrdbms-aad.database.windows.net/.default. Omit ManagedIdentityClientId for a system-assigned managed identity. On AKS, use the workload identity environment variables described above; the default credential chain also supports developer credentials locally. Username is the PostgreSQL principal, not the managed identity client id.

Npgsql obtains a password from the provider whenever it opens a new physical connection. Chronicle shares the token between connections and refreshes it when five minutes or less remain before expiry. Startup checks, database provisioning and schema locks use the same authentication. Native authentication is disabled by default. Do not supply a password or return credentials from a resolver when it is enabled; a resolver may still place databases and select schemas.

The existing connection resolver token path remains available with native authentication disabled. The resolver returns an Entra token as identity.accessToken, which Chronicle uses as the password:

{
"identity": { "userName": "chronicle-kernel", "accessToken": "<entra-access-token>" },
"expiresAt": "2026-10-15T12:00:00Z"
}

Your resolver requests the same PostgreSQL scope and sets expiresAt before the token expires. Chronicle applies the resolved identity each time a connection opens, so a refreshed token takes effect without a restart.

Resolve tenant databases over HTTP with Entra ID

Section titled “Resolve tenant databases over HTTP with Entra ID”

When each tenant, which Chronicle models as a namespace, lives in a database your platform provisions, have Chronicle ask an HTTP endpoint where to connect. Chronicle sends the kind of database, event store, namespace and purpose. Your endpoint answers with a connection string, a schema, an identity and an expiry. The HTTP contract specifies the request and response, and which tenant a request is for explains how scope.namespace maps to your tenant id.

Authenticate Chronicle to your endpoint with the kernel’s managed identity, so there is no shared secret:

Terminal window
Cratis__Chronicle__Storage__CreateIfMissing=false
Cratis__Chronicle__Storage__Schema=chronicle
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Resolver=Http
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Endpoint=https://platform-mgmt.example/internal/connections
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Type=AzureCredential
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Credential=ManagedIdentity
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__ClientId=<managed-identity-client-id>
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Scope=api://platform-mgmt/.default
  • Credential is ManagedIdentity by default. Omit ClientId for a system-assigned identity, and set Credential=WorkloadIdentity on AKS (the Azure SDK variables above must then be present).
  • Scope is the resolver API’s scope. ClientId selects the identity that calls the resolver, not the database identity.
  • Do not also set an Authorization header: both would supply the bearer token, and the resolver rejects that configuration.
  • CreateIfMissing=false stops Chronicle from creating databases, so a database your platform has not provisioned fails with a clear error.
  • With CreateIfMissing=true on SQL Server, kernels coordinate database creation through a lock in master. An identity that cannot open master, such as a contained database user, skips that lock and only checks that its database exists. It cannot create a missing database, so provision those databases up front.

Authenticate the resolver also covers static bearer tokens and OAuth client credentials. A database per tenant on Azure SQL shows a complete resolved setup.

On SQL Server and PostgreSQL, the kernel registers a database health check, named mssql or postgresql, behind the /health endpoint. It connects to the cluster database the way the storage does, through the identity resolved for the cluster at Runtime purpose, and runs SELECT 1. The check times out after three seconds. A rotated token or a managed identity that lost its access therefore turns /health unhealthy, which is what you want a probe to see.

The check covers the cluster database. It does not open a connection to each tenant database. With MongoDB storage, the health check connects with connectionDetails.

For probes from Azure load balancers or Container Apps, publish a dedicated plaintext port rather than fighting certificate validation:

Terminal window
Cratis__Chronicle__Health__Port=8080
Cratis__Chronicle__Health__Tls=false

See Health endpoint for the dedicated port options.

Call Entra-protected endpoints from webhooks

Section titled “Call Entra-protected endpoints from webhooks”

A webhook the kernel calls can authenticate with OAuth client credentials. In the .NET client, register it with WithOAuth(authority, clientId, clientSecret, scope), as in the webhook registration example:

Argument Entra value
authority https://login.microsoftonline.com/<entra-tenant-id>/v2.0
clientId The client id of the app registration that calls the receiver
clientSecret Its client secret, read from your secret store
scope api://<receiver-application-id>/.default

Chronicle discovers the token endpoint from <authority>/.well-known/openid-configuration, requests a token with the client_credentials grant and the scope, and refreshes it shortly before expiry. A 401 triggers one refresh and retry. Keep the secret in your secret store. See OAuth client credentials for the details, and external services for the same scope on external service registrations.

Use the kernel’s managed identity instead of a secret

Section titled “Use the kernel’s managed identity instead of a secret”

Use managed identity when the receiver should accept the kernel’s Azure identity instead of a client secret. The identity belongs to the kernel, not the client registering the webhook, so configure the operator allow-lists before registering it:

Terminal window
Cratis__Chronicle__Webhooks__AllowedHosts__0=receiver.example
Cratis__Chronicle__Webhooks__ManagedIdentity__AllowedScopes__0=api://receiver/.default
Cratis__Chronicle__Webhooks__ManagedIdentity__AllowedClientIds__0=<managed-identity-client-id>
Cratis__Chronicle__Webhooks__ManagedIdentity__AllowSystemAssigned=false

Scopes and client ids are global operator settings only. Empty AllowedScopes disables managed identity webhooks; non-empty client ids must match AllowedClientIds exactly. An empty client id requires AllowSystemAssigned=true, including workload identity’s environment default. Scope matching is exact ignoring case. The receiver must match the existing host allow-list even in Warn mode; event-store host overrides and wildcard subdomains keep their existing meaning. See Managed identity for the JSON configuration and defaults.

Then register the webhook with WithManagedIdentity(scope, clientId). The kernel requests the token with its own Azure identity, as in the managed identity example:

Argument Entra value
scope api://<receiver-application-id>/.default
clientId An approved user-assigned managed identity or workload identity client id. Omit only when AllowSystemAssigned=true
  • No secret is stored with the webhook definition.
  • When the kernel runs with workload identity (for example on AKS), it sees AZURE_FEDERATED_TOKEN_FILE and uses the federated token. Without it, the kernel uses its managed identity. For workload identity, an empty clientId falls back to AZURE_CLIENT_ID.
  • Tokens are cached per client id and scope, and refreshed shortly before expiry. A 401 discards Chronicle’s cached token and the Azure credential instance that supplied it, then retries once. Azure Identity and the identity endpoint control their own caching, so the retry is not guaranteed to receive a different access token.
  • If the kernel host has no usable managed identity, token acquisition fails and the delivery fails. It is retried like any failed delivery and is never reported as delivered.

On Azure SQL and Azure Database for PostgreSQL you can run more than one kernel node by opting in to SQL clustering. It is never on by default: nodes left on the default Localhost type do not join one cluster, even when they share a database. Set the type on every node:

Terminal window
Cratis__Chronicle__Clustering__Type=Sql
Cratis__Chronicle__Clustering__ClusterId=chronicle
Cratis__Chronicle__Clustering__ServiceId=chronicle
  • Sql requires MsSql or PostgreSql storage. SQLite and in-memory storage do not support multi-node clustering, and an unsupported combination fails at startup.
  • Every node must use the same cluster database, schema, clusterId and serviceId.
  • Membership uses the same connection resolution as storage, so the managed identity needs no extra setup.
  • The silo (11111) and gateway (30000) ports must be reachable between nodes. Set advertisedIP when the default address is not.

Clustering lets remaining nodes take over work when a node stops, but it does not guarantee uninterrupted service during a deployment. Test your rollout before relying on it, and follow the rolling-deploy runbook when replacing nodes. The clustering reference covers the remaining options, limits and defunct-silo cleanup.

This is a minimal Azure SQL configuration with HTTP resolution and the dedicated health port, as environment variables for Container Apps or AKS:

Terminal window
# Storage: Azure SQL, authenticated as the managed identity
Cratis__Chronicle__Storage__Type=MsSql
Cratis__Chronicle__Storage__ConnectionDetails='Server=myserver.database.windows.net;Database=chronicle;Authentication=Active Directory Managed Identity;User Id=<managed-identity-client-id>;Encrypt=true'
Cratis__Chronicle__Storage__Schema=chronicle
Cratis__Chronicle__Storage__CreateIfMissing=false
# Per-tenant placement, resolver called as the managed identity
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Resolver=Http
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Endpoint=https://platform-mgmt.example/internal/connections
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Type=AzureCredential
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Credential=ManagedIdentity
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__ClientId=<managed-identity-client-id>
Cratis__Chronicle__Storage__ConnectionResolution__Connection__Http__Authentication__Scope=api://platform-mgmt/.default
# Probes
Cratis__Chronicle__Health__Port=8080
Cratis__Chronicle__Health__Tls=false

If every tenant shares the one database, drop the ConnectionResolution lines and CreateIfMissing=false, so Chronicle can create the databases it derives. For SQL Server, Schema also requires the schema to be the default schema of the user Chronicle connects as, see Schema. Start one node, call /health on port 8080, and expect a healthy response.