AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

azure-prepare

Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.

Original source
microsoft
License
MIT
Pinned revision
3f5b461b2314e01c400564051e92469114c5b68f

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read microsoft--azure-prepare at revision 3f5b461b2314e01c400564051e92469114c5b68f, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 164

references/services/container-apps/day2-operations.md

Container Apps Day-2 Operations

Operational tasks for running Container Apps in production: restart, exec, logs, environment updates, and secret rotation.

Restart and Lifecycle

| Action | Command | |--------|---------| | Restart active revision | az containerapp revision restart -n $APP -g $RG --revision $REV | | Scale to zero (stop) | az containerapp update -n $APP -g $RG --min-replicas 0 --max-replicas <current-max> | | Resume (restore scaling) | az containerapp update -n $APP -g $RG --min-replicas <previous-min> --max-replicas <current-max> | | List replicas | az containerapp replica list -n $APP -g $RG --revision $REV |

💡 Tip: Restarting a revision replaces all running replicas gracefully. No new revision is created.

Exec into a Container

Open a shell inside a running replica for debugging:

# Interactive shell
az containerapp exec -n $APP -g $RG --command /bin/sh

# Target a specific replica and container
az containerapp exec -n $APP -g $RG \
  --replica $REPLICA_NAME \
  --container $CONTAINER_NAME \
  --command /bin/sh

⚠️ Warning: Exec sessions are for debugging only. Changes to the container filesystem are lost on restart.

Log Streaming

Real-time Logs

# Stream system logs
az containerapp logs show -n $APP -g $RG --type system --follow

# Stream application (console) logs
az containerapp logs show -n $APP -g $RG --type console --follow

# Filter to a specific revision or replica
az containerapp logs show -n $APP -g $RG \
  --type console --revision $REV --follow

Log Analytics (KQL)

Query historical logs via the Container Apps environment's Log Analytics workspace:

// Azure Monitor destination (new environments — default)
ContainerAppConsoleLogs
| where ContainerAppName == "my-app"
| where TimeGenerated > ago(1h)
| project TimeGenerated, Log, RevisionName
| order by TimeGenerated desc

// Log Analytics destination (legacy environments)
// ContainerAppConsoleLogs_CL
// | where ContainerAppName_s == "my-app"
// | project TimeGenerated, Log_s, RevisionName_s

Environment Variable Updates

Updating environment variables creates a new revision:

# Set or update env vars
az containerapp update -n $APP -g $RG \
  --set-env-vars "DB_HOST=newhost.postgres.database.azure.com" \
                 "CACHE_TTL=300"

# Remove an env var
az containerapp update -n $APP -g $RG \
  --remove-env-vars "OLD_SETTING"

Bicep — Env Vars with Secret References

configuration: {
  secrets: [
    { name: 'db-password', value: dbPassword }  // or use keyVaultUrl + identity
  ]
}
template: {
  containers: [
    {
      name: 'api'
      image: '${acrName}.azurecr.io/api:latest'
      env: [
        { name: 'DB_HOST', value: dbHost }
        { name: 'DB_PASSWORD', secretRef: 'db-password' }
      ]
    }
  ]
}

Secret Management

Create and Update Secrets

# Add a secret (use Key Vault references in production — avoid plaintext secrets)
az containerapp secret set -n $APP -g $RG \
  --secrets "db-password=<secret-value>"

# Reference a Key Vault secret (managed identity required)
az containerapp secret set -n $APP -g $RG \
  --secrets "db-password=keyvaultref:https://myvault.vault.azure.net/secrets/db-pwd,identityref:/subscriptions/.../userAssignedIdentities/my-id"

⚠️ Warning: Avoid passing plaintext secrets on the command line — they may appear in shell history and process listings. Prefer Key Vault references. If you must use plaintext, use shell substitution like --secrets "key=$(cat secret.txt)" to avoid literals on the command line.

💡 Tip: Use Key Vault references instead of plain-text secrets. The Container App pulls the latest value on each new revision or replica start.

Secret Rotation Workflow

  1. Update the secret value in Key Vault
  2. Create a new revision to pick up the updated value:
    az containerapp revision copy -n $APP -g $RG
    
  3. Verify the new revision is healthy
  4. Shift traffic to the new revision

⚠️ Warning: Existing replicas do NOT hot-reload Key Vault references. A new revision or replica restart is required.

Health Monitoring

| Check | How | |-------|-----| | Revision health | az containerapp revision list -n $APP -g $RG -o table | | Replica status | az containerapp replica list -n $APP -g $RG --revision $REV | | System logs | az containerapp logs show -n $APP -g $RG --type system | | Metrics | Azure Monitor → Container Apps → Requests, Replicas, CPU, Memory |

Common Troubleshooting

| Symptom | Likely Cause | Remediation | |---------|-------------|-------------| | Replica crash loop | App startup failure | Check console logs; exec into container | | 0 replicas running | Scale-to-zero + no traffic | Set minReplicas: 1 or send a request | | Env var not updating | Old revision still serving traffic | Verify the latest revision exists, then update ingress traffic weights or route to latestRevision | | Secret value stale | Key Vault ref not refreshed | Create or verify the refreshed revision, then shift traffic to that revision | | High memory/CPU | Resource limits too low | Update resources.cpu / resources.memory |