azure-cliazure-front-door

Configuring Azure Front Door (with Azure CLI): Adding route with multiple custom domains


I am configuring AFD with az cli and I am running in an issue. I have two custom domains:

    $afd_custom_domain_1="www-mydomain-com"     #this is id for domain 1
    $afd_custom_domain_2="mydomain-com"         #this is id for domain 2
    
    az afd route create \
        --resource-group "$_resource_group" \
        --profile-name "$_profile_name" \
        --endpoint-name "$_endpoint_name" \
        --route-name "$_route_name" \
        --origin-group "$_origin_group_name" \
        --patterns-to-match "/*" \
        --origin-path "/" \
        --https-redirect Enabled \
        --forwarding-protocol MatchRequest \
        --custom-domains "$afd_custom_domain_1 $afd_custom_domain_2"

I am trying to add them like this --custom-domains "$afd_custom_domain_1 $afd_custom_domain_2" but it fails. I thought I saw in documentation that I caould add them this way. But doesnt seem to work.


Solution

  • The --custom-domains parameter expects either a space-separated list, JSON or YAML file with a list of domains according to the official documentation here.

    Your issue is that your quoting the full argument string: "$afd_custom_domain_1 $afd_custom_domain_2" which makes the command treat this as a single argument (domain).

    You'll want to try:

    --custom-domains "$afd_custom_domain_1" "$afd_custom_domain_2"
    

    or:

    --custom-domains $afd_custom_domain_1 $afd_custom_domain_2