Containers Azure Container Apps field-manual-complete field-manual-complete

Container Apps secret

A Container Apps secret is a protected value attached to a container app, such as a password, connection string, API token, registry credential, or Key Vault reference. Instead of writing the value into an image or template, the app can reference the secret at runtime. Secrets are app-scoped, while revisions consume them through environment variables, scale rules, or image pull settings. This distinction matters because changing a secret is not the same as safely restarting or replacing every revision that depends on it.

Aliases
Container Apps secret, app-service-app-setting, client-secret, container apps secret, container-apps, container-apps-environment-variable, container-apps-revision, container-apps-secret, container-registry, keda, key-vault, key-vault-access-policy, managed-identity, secret
Difficulty
intermediate
CLI mappings
5
Last verified
2026-05-30

Microsoft Learn

Microsoft Learn describes Container Apps secrets as application-scoped values that can be stored directly or referenced from Azure Key Vault. Revisions can use them through environment variables, registry credentials, or scale rules, while managed identity controls access to Key Vault references. during application configuration and rotation.

Microsoft Learn: Manage secrets in Azure Container Apps2026-05-30

Technical context

Technically, Container Apps secrets live on the container app resource inside a Container App environment. They can store literal values or reference Azure Key Vault secrets through managed identity. Revisions refer to secret names, and environment variables can use secret references instead of plain text. Secrets may also support registry authentication or scaler authentication. Azure Resource Manager controls the configuration, while the data plane uses the values during startup, scaling, image pull, and dependency calls. Secret lifecycle is tied to identity, revision behavior, and operational rollout.

Why it matters

Container Apps secrets matter because credentials are one of the easiest ways to turn a small configuration mistake into an outage or exposure. A leaked connection string can compromise data; a stale secret can break every replica on restart; a deleted secret can silently affect a scale rule; and a Key Vault permission error can stop a new revision from becoming healthy. Good secret handling gives teams safer rotation, cleaner separation from source code, stronger audit evidence, and less panic during credential expiry. It also teaches that secret storage and secret rollout are different operational problems. It also keeps rotation evidence clear when credentials change under pressure.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In the Container Apps Secrets blade, you see secret names, Key Vault reference settings, identity choices, and update actions without exposing protected secret values. during rotation reviews.

Signal 02

In container app YAML, Bicep, or ARM, secret references appear in configuration, environment variables, registry credentials, and scale rule authentication blocks. during secure rotation reviews.

Signal 03

In logs and deployment failures, missing secret names, Key Vault permission errors, image pull failures, and dependency authentication messages reveal broken secret wiring. during deployment reviews.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Rotate a database connection secret without rebuilding the container image or exposing the value in source control.
  • Reference Key Vault secrets through managed identity so production credentials stay governed outside the app template.
  • Store registry credentials or scaler authentication values needed by a container app at startup or during scale decisions.
  • Recover from expired credentials by identifying affected revisions, updating the secret, and validating dependency health.
  • Remove retired secrets after confirming no active revision, environment variable, or scale rule still references them.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Insurance API rotates database credential

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An insurance claims platform had a database password expiring during month-end processing. Previous rotations required rebuilding images and often caused missed claim-status updates.

Business/Technical Objectives
  • Rotate the database credential without rebuilding container images.
  • Keep claim processing unavailable for less than five minutes.
  • Prevent secret values from appearing in pipeline logs or tickets.
  • Prove which revisions consumed the updated credential.
Solution Using Container Apps secret

The team moved the claims API connection string into a Container Apps secret referenced by an environment variable. The rotation runbook used Azure CLI from a secure administrative workstation to list secret names, set the new value, and confirm the app configuration still referenced the approved secret name. Operators then triggered a controlled revision rollout so new replicas loaded the updated value while the previous revision remained available for rollback. Application Insights dashboards watched database login failures, queue backlog, and claim update latency. The change record captured secret name, app name, revision names, identity used for the command, and validation queries, but never stored the secret value itself.

Results & Business Impact
  • Credential rotation completed in four minutes and twelve seconds.
  • Claim-status queue backlog stayed below the 1,000-message warning threshold.
  • No password value appeared in release logs, screenshots, or support tickets.
  • The audit team confirmed every active revision used the approved secret reference.
Key Takeaway for Glossary Readers

A Container Apps secret makes credential rotation operationally manageable when rollout and evidence are designed with it.

Case study 02

Gaming backend adopts Key Vault references

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A mobile game backend stored third-party matchmaking API tokens as plain pipeline variables, and a misconfigured debug step printed one token during a weekend tournament.

Business/Technical Objectives
  • Move production tokens out of pipeline variables and app templates.
  • Use managed identity to retrieve Key Vault-backed secret references.
  • Rotate exposed credentials without interrupting tournament matchmaking.
  • Reduce the number of engineers who could view raw token values.
Solution Using Container Apps secret

The platform team created Key Vault secrets for each external gaming partner and configured Container Apps secrets as Key Vault references. The container app system-assigned managed identity received only the Key Vault Secrets User permission needed to retrieve those values. Pipelines stopped passing raw tokens and instead deployed configuration that referenced secret names. During rotation, operators updated Key Vault versions, confirmed the container app secret references, and rolled out a new revision during low traffic. Dashboards watched matchmaking latency, failed partner calls, and replica restarts. Access reviews later showed that raw production token visibility moved from the build team to a small security-controlled vault owner group.

Results & Business Impact
  • Raw token access dropped from eighteen engineers to four approved vault owners.
  • Tournament matchmaking error rate stayed below 0.3 percent during rotation.
  • Secret-related pipeline log findings fell to zero in the next security scan.
  • Partner token rotation time decreased from two hours to twenty-five minutes.
Key Takeaway for Glossary Readers

Key Vault-backed Container Apps secrets separate deployment automation from credential visibility while keeping apps practical to operate.

Case study 03

Manufacturing scheduler fixes scaler secret

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A factory scheduling app used a Container Apps scale rule to read a Service Bus queue, but replicas stopped scaling after a connection secret was renamed during cleanup.

Business/Technical Objectives
  • Restore queue-based scaling before the next production shift.
  • Identify every scale rule and environment variable using the renamed secret.
  • Prevent future cleanup from deleting active authentication references.
  • Lower manual incident triage time for scaler failures.
Solution Using Container Apps secret

Operators used CLI commands to list the container app secrets and inspect the scale rule authentication block. They found that the secret name used by the KEDA scaler no longer existed, while the application environment variable had already been updated to the new name. The team restored the expected secret reference, restarted the affected revision, and watched queue depth, replica count, and processing latency return to normal. After the incident, they added a pre-delete checklist requiring teams to search container app configuration for secretRef usage before removing any secret. The runbook also recorded safe CLI queries that showed secret names and references without displaying protected values.

Results & Business Impact
  • Queue processing recovered before the next shift handoff, avoiding delayed work orders.
  • Scaler triage time fell from ninety minutes to eighteen minutes in the follow-up drill.
  • Unauthorized secret deletions dropped to zero after the pre-delete checklist shipped.
  • Replica scale-out returned to the expected ten-replica peak during production bursts.
Key Takeaway for Glossary Readers

Container Apps secrets are part of scaling architecture, not just application configuration.

Why use Azure CLI for this?

As an Azure engineer, I use Azure CLI for Container Apps secrets because secret work needs precision and a useful audit trail. The portal can hide whether a secret is app-scoped, Key Vault-backed, or referenced by a revision. CLI commands let me list secret names, set a new value or Key Vault reference, check managed identity configuration, and coordinate restarts or new revisions through scripts. During rotations, the CLI helps teams separate safe read-only discovery from approved updates, capture before-and-after evidence, and avoid exposing values in screenshots, tickets, shell history, or chat transcripts. That evidence keeps rotations controlled when access failures are urgent.

CLI use cases

  • List secret names for a container app and compare them against approved dependency inventory without printing values.
  • Set a new secret value or Key Vault reference during an approved rotation window.
  • Remove an unused secret after confirming no active revision or scale rule still depends on it.
  • Inspect managed identity and role assignments before using Key Vault-backed secret references.
  • Export safe configuration evidence showing secret names, references, and consuming settings for audit review.

Before you run CLI

  • Confirm tenant, subscription, resource group, app name, and environment before touching secrets in production.
  • Use a secure shell and avoid commands that place secret values in shared terminal history or pipeline logs.
  • Verify RBAC, managed identity, and Key Vault permissions before setting Key Vault-backed references.
  • Identify active revisions, scale rules, and environment variables that depend on the secret before rotation.
  • Plan restart, redeploy, or traffic movement behavior because changing a secret value may not refresh every running container.

What output tells you

  • Secret list output confirms which secret names exist without exposing the protected values themselves.
  • Key Vault reference fields show whether the app depends on managed identity and an external vault URI.
  • Container app configuration reveals which environment variables, registry credentials, or scale rules consume secret names.
  • Identity output explains which principal must have permission to retrieve a Key Vault secret at runtime.
  • Revision and replica status after rotation shows whether the app restarted cleanly and dependencies authenticated successfully.

Mapped Azure CLI commands

Container Apps secret CLI commands

direct
az containerapp secret list --name <app-name> --resource-group <resource-group> --output table
az containerapp secretdiscoverContainers
az containerapp secret set --name <app-name> --resource-group <resource-group> --secrets <secret-name>=<secret-value>
az containerapp secretsecureContainers
az containerapp secret set --name <app-name> --resource-group <resource-group> --secrets <secret-name>=keyvaultref:<key-vault-secret-uri>,identityref:system
az containerapp secretsecureContainers
az containerapp secret remove --name <app-name> --resource-group <resource-group> --secret-names <secret-name>
az containerapp secretremoveContainers
az containerapp show --name <app-name> --resource-group <resource-group> --query properties.configuration.secrets
az containerappdiscoverContainers

Architecture context

In architecture reviews, I place Container Apps secrets at the boundary between application configuration, identity, and dependency access. A secret is not only a value; it is a dependency contract that decides how the app reaches databases, queues, APIs, registries, and scalers. I prefer Key Vault references with managed identity for production so rotation and access control are centralized. I also define restart or revision rollout behavior because changing the source value does not guarantee every running container has reloaded it. The architecture must cover ownership, naming, access, rotation windows, monitoring, and rollback. Make the secret path explicit in diagrams, runbooks, and ownership records.

Security

Security impact is direct and high. Secrets should never be stored in container images, source repositories, pipeline logs, or plain template outputs. Use managed identities, Key Vault references, least-privilege RBAC, private endpoints where needed, and strict access to secret-setting commands. Remember that anyone who can update app secrets can often change what production code can access. Review secret names, not secret values, during audits; avoid printing values; rotate credentials on schedule; and verify that old revisions, inactive revisions, and scale rules no longer depend on retired secrets. Review every reference because one leaked value can unlock many downstream systems quickly.

Cost

Secrets do not usually create a large bill by themselves, but poor secret management drives indirect cost. Failed authentication causes retries, extra replicas, queue buildup, dependency throttling, longer incidents, and higher log ingestion. Key Vault usage, private endpoint networking, diagnostic retention, and duplicate rotation environments also have cost implications. The biggest FinOps issue is operational waste: teams spend hours finding which secret broke a release or which stale credential still exists. Good naming, ownership, and automated evidence reduce both cloud cost and human recovery time. Ownership matters. Track Key Vault usage because rotation, retries, and noisy failures can raise operating cost.

Reliability

Reliability depends on how secrets are rotated and consumed. A secret update can break startup, image pulls, database connections, queue processing, or autoscaling if dependent revisions are not restarted or redeployed correctly. Key Vault outages, permission changes, deleted versions, and managed identity mistakes can also prevent a healthy release. Operators should test rotations in lower environments, identify every secret reference, confirm fallback credentials where appropriate, and sequence rollout carefully. The safest runbooks pair secret updates with health checks, replica readiness checks, dependency probes, and a rollback plan. Test rotation steps because stale replicas can keep using credentials that should be retired.

Performance

Performance impact is usually indirect, but it can be painful. A bad secret can slow startup through repeated authentication failures, cause dependency calls to retry, prevent scalers from reading queues, or force replicas into crash loops. Key Vault-backed references add a dependency that must be available and authorized before the app can use the value. Operators should watch startup duration, restart counts, authentication errors, dependency latency, queue depth, and scale rule behavior after secret changes. Fast secret rotation is not successful unless the app reaches stable performance afterward. Measure startup after changes because blocked vault access can delay scale-out quickly.

Operations

Operationally, Container Apps secrets require a clear inventory of names, owners, dependency purpose, rotation cadence, Key Vault location, identity, and consuming revisions. Teams should list secrets without exposing values, document which environment variables and scale rules reference them, and schedule rotations with application owners. Change records should include the identity used, Key Vault secret URI when applicable, affected app, expected restart behavior, and validation query. Operators also need cleanup procedures for retired secrets, because unused credentials create risk and make incident response more confusing. Review notes matter. Document the credential owner so support can rotate, restart, and prove recovery quickly safely.

Common mistakes

  • Assuming updating a secret automatically restarts all running containers or creates a new revision.
  • Printing secret values in deployment logs, chat tickets, command history, or exported troubleshooting files.
  • Deleting a secret before checking environment variables, registry configuration, and scale rule authentication references.
  • Using Key Vault references without granting the container app managed identity the required secret access.
  • Reusing broad credentials across environments, which turns a dev leak into a production incident.