Secrets
Secrets are group-scoped key-value stores. Create them once on the sandbox group, then reference them from egress header transforms or telemetry authentication.
Create or update a secret
Secrets live on the sandbox group. Values are not auto-injected as environment variables. Reference them from supported sandbox group configuration such as egress-policy header transforms and OTLP telemetry authentication.
- Open sandboxes.azure.com/sandbox-groups and select your sandbox group.
- Select Secrets.
- Select Create.
- Enter a name, such as
model-credentials. - Add key-value pairs, such as
API_KEYandMODEL. - Select Save. To rotate values later, select the secret, enter replacement values, and save again.
- Bash
- PowerShell
- SDK
aca sandboxgroup secret set \
--name model-credentials \
--key API_KEY \
--value sk-test-123
aca sandboxgroup secret set \
--name model-credentials \
--key MODEL \
--value gpt-4
aca sandboxgroup secret set \
--name model-credentials \
--key API_KEY \
--value sk-updated-456
aca sandboxgroup secret set `
--name model-credentials `
--key API_KEY `
--value sk-test-123
aca sandboxgroup secret set `
--name model-credentials `
--key MODEL `
--value gpt-4
aca sandboxgroup secret set `
--name model-credentials `
--key API_KEY `
--value sk-updated-456
from azure.identity import DefaultAzureCredential
from azure.containerapps.sandbox import SandboxGroupClient, endpoint_for_region
credential = DefaultAzureCredential()
client = SandboxGroupClient(
endpoint_for_region(ACA_SANDBOXGROUP_REGION),
credential,
subscription_id=AZURE_SUBSCRIPTION_ID,
resource_group=ACA_RESOURCE_GROUP,
sandbox_group=ACA_SANDBOX_GROUP,
)
client.upsert_secret(
"model-credentials",
{"API_KEY": "sk-test-123", "MODEL": "gpt-4"},
)
client.upsert_secret(
"model-credentials",
{"API_KEY": "sk-updated-456", "MODEL": "gpt-4o"},
)
List secrets and keys
List secrets to confirm that a name exists. List keys to see which entries are present without reading the stored values.
- Open the sandbox group and select Secrets.
- Review the secret list.
- Select a secret to view its key names.
- Use the search box to filter by secret name.
- Bash
- PowerShell
- SDK
aca sandboxgroup secret show --name model-credentials
aca sandboxgroup secret show --name model-credentials --key API_KEY
aca sandboxgroup secret show --name model-credentials
aca sandboxgroup secret show --name model-credentials --key API_KEY
for secret in client.list_secrets():
print(secret.id)
keys = client.list_secret_keys("model-credentials")
print(keys)
Inspect metadata and values
Use metadata checks to confirm the secret shape. Use value reveal or SDK value peek only inside trusted code paths, and avoid printing full values to logs.
The portal detail panel can reveal and copy an individual saved secret value. Handle revealed values carefully, and avoid pasting them into logs or shared channels.
- Bash
- PowerShell
- SDK
aca sandboxgroup secret list
aca sandboxgroup secret list
keys = client.list_secret_keys("model-credentials")
print(keys)
peek = client.peek_secret("model-credentials")
for name, value in (peek.values or {}).items():
masked = value[:3] + "***" if value else ""
print(name, masked)
Remove keys or delete a secret
Remove a key to keep the bundle and its remaining values. Delete the bundle only after every sandbox that needs it has moved to a replacement.
- Open the sandbox group and select Secrets.
- Select the secret.
- Select Delete and confirm.
- Bash
- PowerShell
- SDK
aca sandboxgroup secret remove \
--name model-credentials \
--key MODEL \
--yes
aca sandboxgroup secret delete \
--name model-credentials \
--yes
aca sandboxgroup secret remove `
--name model-credentials `
--key MODEL `
--yes
aca sandboxgroup secret delete `
--name model-credentials `
--yes
client.delete_secret("model-credentials")
client.close()
credential.close()