skip to content
Alvin Lucillo

Referencing secret value from env var

/ 1 min read

Last day’s entry, we’ve seen how we’ve created a secret key embeddings-api-key for the container app. Now, to reference its value from an environment variable.

az containerapp update -n $CONTAINER_APP_NAME -g $RESOURCE_GROUP \
    --set-env-vars EMBEDDINGS_API_KEY=secretref:embeddings-api-key
{
  "id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.App/containerApps/<APP_NAME>",
  "location": "<LOCATION>",
  "name": "<APP_NAME>",
  "properties": {
    "configuration": {
      "secrets": [
        {
          "name": "embeddings-api-key"
        }
      ]
    },
    "latestRevisionName": "<APP_NAME>--<REVISION_SUFFIX>",
    "provisioningState": "Succeeded",
    "runningStatus": "Running",
    "template": {
      "containers": [
        {
          "env": [
            {
              "name": "MODEL_NAME"
            },
            {
              "name": "EMBEDDINGS_API_KEY",
              "secretRef": "embeddings-api-key"
            }
          ],
          "image": "<ACR_NAME>.azurecr.io/<IMAGE_NAME>:<TAG>",
          "name": "<CONTAINER_NAME>"
        }
      ]
    }
  },
  "resourceGroup": "<RESOURCE_GROUP>",
  "type": "Microsoft.App/containerApps"
}