I have Azure Container App and Azure Container Registry.
When I create new Azure Container App manually via Portal, it does not allow that
Cannot access ACR 'acrname.azurecr.io' because admin credentials on the ACR are disabled.
When I enable Admin user of Azure Container Registry, it works of course. As I read it is suggested to be disabled. My only question, is it possible to consume registry via portal for given users, without enabling admin user?
To consume an Azure Container Registry in a Container App environment via the Azure portal, the admin user of the registry needs to be enabled. However, it is recommended to disable the admin user for security reasons. One solution is to enable the admin user to configure the Container App through the portal. After setting up, disable the admin user and rely on the service principal for runtime authentication from the Container App.
az acr update -n <acr_name> --admin-enabled false
Another possible solution is to use a managed identity or service principal to pull images from the registry, which eliminates the need for admin credentials.
To securely connect an Azure Container App to an Azure Container Registry (ACR) without enabling the ACR admin user, you can use a managed identity or a service principal.
Below are detailed steps for both methods
If for some reason you prefer using a service principal over a managed identity, follow these steps:
Goto Microsoft Entra ID-> app registration-> create new registration-> give a name-> choose tenant type and register.
Once created, note down the client id, tenant id, and go to certificates and secrets and create a secret which you will use later for authentication.
then go to your acr and under IAM add roles, you can add acr pull, push or straightaway owner role for complete access. Make sure to select service principal option.
Also ensure you have the roles assigned under your resource group and subscription level as well to avoid permission denied error message. goto your resource-group -> IAM-> Add roles-> add your choice of roles-> select service principal
repeat the process under your subscription as well
Now try connecting to your acr via azure cli or command prompt using-
az login --service-principal --username <app_id> --password <client_secret> --tenant <tenant_id>
With the service principal configured in your Azure Container App settings, it will use these credentials to pull the container image from ACR during deployment.
References: