Automation

Azure Container Apps Dapr: diagnose component initialization before restarting revisions

A production runbook for isolating Dapr component initialization failures across scope, identity, secret stores and downstream services before changing timeouts or restarting Azure Container Apps revisions.

18 Oct 2026 azurecontainer-appsdaprcomponentsmanaged-identitykey-vaultservice-busobservabilitykqlautomationrunbookrollbackproduction

An Azure Container Apps application starts returning errors when it publishes through a Dapr component. The application container is healthy, but the Dapr sidecar reports that the component could not initialize. Under pressure, increasing initTimeout, enabling ignoreErrors or restarting every revision can look like a quick recovery. Each action can hide a different failure and expand the incident to other applications in the environment.

The running case is an order API using a Dapr pub/sub component backed by Azure Service Bus. Its component retrieves no static credential because it uses a user-assigned managed identity. The same method applies to state stores, bindings and secret stores. The goal is to prove whether the failure belongs to component selection, configuration, identity, secret resolution, network reachability or the downstream service, then choose repair, bounded degraded operation or rollback.

Freeze the effective contract

A Dapr component is an environment-level resource. Unless it has explicit scopes, every Dapr-enabled application in the environment can load it. Its scope values are Dapr application IDs, not Container App resource names. Record the effective contract before editing it.

yaml 01-dapr-component-incident.yml
incident: INC-DAPR-418
environment: cae-prod-we
container_app: orders-api-prod
revision: orders-api-prod--20261018-1
dapr_app_id: orders-api
component:
name: orders-pubsub
type: pubsub.azure.servicebus.queue
version: v1
scopes: [orders-api, billing-worker]
init_timeout: 5s
ignore_errors: false
authentication:
mode: user_assigned_managed_identity
client_id: <managed-identity-client-id>
dependency: orders-prod.servicebus.windows.net
last_known_good:
component_commit: <commit>
revision: orders-api-prod--20261017-3
stop_owner: platform-on-call

Keep the deployed component export, its IaC source, the Container App revision definition and UTC timestamps. Do not place secret values in the incident record.

Prove which applications load the component

First compare the component scopes with the Dapr application ID that actually runs in each affected app.

bash 02-component-and-app-scope.sh
set -eu

RG="rg-platform-prod"
ENV="cae-prod-we"
APP="orders-api-prod"
COMPONENT="orders-pubsub"

az containerapp show --resource-group "$RG" --name "$APP" --query '{latestRevision:properties.latestRevisionName,dapr:properties.configuration.dapr,identity:identity}' --output json

az containerapp env dapr-component show --resource-group "$RG" --name "$ENV" --dapr-component-name "$COMPONENT" --output yaml

az containerapp env dapr-component list --resource-group "$RG" --name "$ENV" --query '[].{name:name,type:properties.componentType,scopes:properties.scopes,ignoreErrors:properties.ignoreErrors,initTimeout:properties.initTimeout}' --output table

An empty scope is broad exposure, not proof that the component belongs to every app. A scope containing the Container App name while the runtime uses another Dapr app ID is also a configuration error. Compare a healthy consumer and a failing consumer before changing the shared resource.

Rebuild the initialization timeline

Use platform logs for component lifecycle and console logs for the Dapr sidecar. The useful question is not only whether initialization failed, but when, on which revision and after which configuration change.

bash 03-live-dapr-evidence.sh
az containerapp logs show --resource-group "$RG" --name "$APP" --type system --tail 100

az containerapp revision list --resource-group "$RG" --name "$APP" --query '[].{revision:name,active:properties.active,created:properties.createdTime,health:properties.healthState,replicas:properties.replicas}' --output table

# Select the failing revision and replica before streaming console logs.
az containerapp replica list --resource-group "$RG" --name "$APP" --revision "<revision-name>" --output table

Retain the exact Dapr error family: component not found, secret retrieval, token acquisition, authorization, name resolution, connection timeout, TLS, broker rejection or schema/configuration parsing. A generic application 500 is downstream evidence, not the root cause.

Correlate component and sidecar logs in KQL

Container Apps console tables include Dapr sidecar output. Table and column names differ depending on whether logs are sent directly to Log Analytics or through diagnostic settings, so adapt the query to the table enabled in the environment.

kusto 04-dapr-component-initialization.kql
let Start = datetime(2026-10-18T05:30:00Z);
let End = datetime(2026-10-18T06:15:00Z);
let App = "orders-api-prod";
union isfuzzy=true
(
ContainerAppConsoleLogs_CL
| extend AppName = tostring(ContainerAppName_s),
         Revision = tostring(RevisionName_s),
         Container = tostring(ContainerName_s),
         Message = tostring(Log_s)
),
(
ContainerAppConsoleLogs
| extend AppName = tostring(ContainerAppName),
         Revision = tostring(RevisionName),
         Container = tostring(ContainerName),
         Message = tostring(Log)
)
| where TimeGenerated between (Start .. End)
| where AppName == App
| where Message has_any ("component", "orders-pubsub", "error initializing", "secret", "timeout", "unauthorized")
| project TimeGenerated, AppName, Revision, Container, Message
| order by TimeGenerated asc

Join this timeline with Azure Activity for component updates and role assignments, plus Service Bus or Key Vault diagnostics when enabled. The first failure after a component write is strong direction, but still validate the rejected dependency call before attributing cause.

Test each boundary independently

Initialization crosses several boundaries. Test them in order so one success does not stand in for the whole chain.

text 05-initialization-boundaries.txt
Selection
Component exists in the expected environment
Scope contains the runtime Dapr app ID
Component type and version match the intended building block

Configuration
Required metadata names are present
Namespace or endpoint is fully qualified
Secret references point to an existing secret store component

Identity
The intended managed identity is attached to every scoped app
azureClientId is the client ID when a user-assigned identity is used
Minimum data-plane role exists at the dependency scope

Network and dependency
Runtime DNS resolves the dependency as designed
Route, firewall and private access permit the exact destination
Service Bus, Key Vault or state store is healthy and accepts a canary

Runtime
Sidecar loads the component on one canary replica
Publish, state or binding operation completes once
Application handles component unavailability without duplicate effects

For Azure-hosted components, prefer managed identity when the component supports it. Do not replace an identity diagnosis with a client secret. If a Key Vault secret store is used, validate both identity access to Key Vault and the referenced secret; success at Key Vault does not prove access to the final component backend.

Do not use timeout and ignoreErrors as diagnosis

initTimeout answers one narrow question: how long Dapr waits for initialization. It can help when a healthy dependency is predictably slow, but it does not repair a wrong scope, role, hostname or secret reference.

ignoreErrors: true allows the sidecar to continue when component initialization fails. That may keep unrelated application paths alive, but the failed building block remains unavailable. Enable it only when the application has a tested degraded mode, alerts on component readiness and cannot acknowledge work that was never persisted or published.

Before either change, define a canary:

yaml 06-component-canary.yml
canary:
app_id: orders-api-canary
component_scope_added: true
operation: publish_one_synthetic_order
idempotency_key: INC-DAPR-418-canary-01
expected:
  - sidecar_initializes_component
  - broker_accepts_one_message
  - consumer_observes_same_id_once
  - no_unscoped_app_loads_component
stop_when:
  - duplicate_message
  - unexpected_consumer_receives_event
  - identity_or_endpoint_differs_from_contract
  - initialization_exceeds_change_window

Canary scope is a security boundary as well as a rollout tool. Do not remove all scopes to make the test easier.

Decide repair, degraded operation or rollback

text 07-dapr-decision-gate.txt
REPAIR
Wrong app ID, metadata, identity, role or endpoint is proven
One bounded configuration change corrects the failed boundary
Canary initializes and completes the real component operation

DEGRADED OPERATION
Application has a tested path that does not require the component
ignoreErrors is explicitly approved and observable
No event, state transition or acknowledgement can be lost
Recovery owner and deadline are recorded

ROLL BACK
Failure starts with a component or identity change
Previous component artifact and permissions remain qualified
Canary cannot prove the new configuration inside the window
Shared-environment blast radius is growing

DO NOT CLOSE
Success only follows an unbounded restart
A broad role or secret replaced managed identity
Component is exposed to every app without intent
Publish succeeds but delivery or state persistence is unverified

Rollback the component artifact and the associated identity or network change as one recorded release, then restart only the scoped applications that need it if runtime reload is required. A mass restart before restoring the dependency can create more replicas with the same failure and erase the useful comparison with a healthy revision.

Validate the business effect

Initialization success is necessary but insufficient. Execute the smallest real operation through the Dapr API, retain its correlation or message ID, and prove the downstream effect exactly once. Compare sidecar errors, application errors, dependency diagnostics, latency and backlog with the pre-incident baseline.

Close only when the component is scoped to intended app IDs, the expected identity reaches the expected backend, a fresh replica loads it, the synthetic operation completes exactly once and temporary permissions or ignoreErrors settings have been removed or formally accepted.

Conclusion

A Dapr component initialization failure is a dependency-chain incident, not a restart instruction. The component resource, app ID scope, identity, secret resolution, network path, backend and sidecar all have separate evidence.

The operational decision stays bounded: repair the single failed boundary, use degraded mode only when the business path is designed for it, or restore the last qualified component contract. A green revision is not the final proof; the final proof is one controlled Dapr operation reaching its intended effect without widening access or duplicating work.