Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
394 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello community!
I have a problem using the python SDK when trying create a Container app from docker image already up in my ACR.
Im using the ACR administrator credentials (already enabled in Settings > Access key).
My python code look like this:
from azure.identity import ClientSecretCredential
from azure.mgmt.appcontainers import ContainerAppsAPIClient
tenant_id = 'XXXXX'
client_id = 'XXX'
client_secret = 'XXX'
subscription_id = 'XXX'
resource_group = 'resource-group'
environment_name = 'env-name'
version = '1.0.0'
image_name = 'my-api'
acr_name = 'myacrname'
container_app_name='container-name'
docker_registry_username = 'acrname'
docker_registry_password = 'XXX'
client = ContainerAppsAPIClient(
credential=ClientSecretCredential(
tenant_id=tenant_id,
client_id=client_id,
client_secret=client_secret
),
subscription_id=subscription_id,
)
environment_id = f'/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.App/managedEnvironments/{environment_name}'
response = client.container_apps.begin_create_or_update(
resource_group_name=resource_group,
container_app_name=container_app_name,
container_app_envelope={
"location": "East US",
"properties": {
"configuration": {
"ingress": {
"external": True,
"targetPort": 80,
"transport": "http",
"stickySessions": {
"affinity": "none"
}
},
"maxInactiveRevisions": 10,
"registries": [
{
"server": f"{acr_name}.azurecr.io",
"username": docker_registry_username,
"passwordSecretRef": "docker-pwd"
}
],
"secrets": [
{
"name": "docker-pwd",
"value": docker_registry_password
}
]
},
"environmentId": environment_id,
"template": {
"containers": [
{
"image": f"{image_name}:{version}",
"name": container_app_name,
"probes": [
{
"httpGet": {
"httpHeaders": [{"name": "Custom-Header", "value": "Awesome"}],
"path": "/health",
"port": 8080,
},
"initialDelaySeconds": 3,
"periodSeconds": 3,
"type": "Liveness",
}
]
}
],
"revisionSuffix": "cxx",
"scale": {
"maxReplicas": 5,
"minReplicas": 1
},
},
},
},
).result()
print(response.json())
This code returns this error:
(ContainerAppOperationError) Failed to provision revision for container app 'container-name'. Error details: The following field(s) are either invalid or missing. Field 'template.containers.container-name.image' is invalid with details: 'Invalid value: "myacrname.azurecr.io/my-api:1.0.0": GET https:?scope=repository%3Amy-api%3Apull&service=myacrname.azurecr.io: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.';..
Any ideas?
Extra Data:
My client id to authentication using ClientSecretCredetial, have Contributior permissions.