Bind managed certificate to custom domain container app with az cli

Riccardo Barbieri 60 Reputation points
2024-07-07T11:54:40.9866667+00:00

I am trying to provision and then bind a managed certificate to a custom domain for an Azure Container App but I am getting an error.

I used this command to create the certificate

az containerapp env certificate create -g $RESOURCE_GROUP -n $CONTAINER_APP_ENV_NAME --hostname $CUSTOM_DOMAIN --validation-method CNAME

The certificate is created correctly, I checked both on azure portal and with the command

az containerapp env certificate list -g $RESOURCE_GROUP -n $CONTAINER_APP_ENV_NAME --managed-certificates-only --output tsv

In the output of the last command I get the name of the certificate created.

I use the name of the cert with the command

az containerapp hostname bind -g $RESOURCE_GROUP -n $CONTAINER_APP_NAME --hostname $CUSTOM_DOMAIN --environment $CONTAINER_APP_ENV_NAME --certificate $CERTIFICATE_NAME --validation-method CNAME

The problem is with this command that returns the following error: The certificate <certificate_name> does not exist in Container app environment <env_name>.

I don't understand what I am doing wrong, can someone help?

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
415 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. akinbade abiola 16,090 Reputation points
    2024-07-08T06:43:09.67+00:00

    Hello Riccardo Barbieri,

    Thanks for your question.

    Ensure that the certificate is indeed created and associated. Use Azure CLI:

    az containerapp env certificate list --name $name--resource-group $RG

    If the certificate exists try binding: https://learn.microsoft.com/en-us/cli/azure/containerapp/hostname?view=azure-cli-latest#az-containerapp-hostname-bind

    az containerapp hostname bind -g $RESOURCE_GROUP -n $CONTAINER_APP_NAME --hostname --environment $CONTAINER_APP_ENV_NAME --certificate $CERTIFICATE_ID 
    
    

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Abiola

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.