Forum Discussion

WilliamBonomo's avatar
WilliamBonomo
Brass Contributor
Oct 21, 2022
Solved

Frontdoor Custom Domain in Bulk

Hi Everyone.

 

We are on the brink of migrating our onprem workload to Azure AKS.

We have hundreds of clients and every client has its own subdomain p.e client1.contoso.com.

 

To avoid unexpected overload we'll migrate them in batches and for that, we'll need to create custom domains on Azure Frondoor to forward the clients included in those batches to the correct cluster. The batches are composed of 40-50 clients and creating these custom domains one by one would be a pain.

 

I wrote a bash loop to create the custom domains from a csv file using the following command, which works fine when creating only one domain but it doesn't if I edit it for the loop.

 

 

az afd custom-domain create -g rg-test-frontdoor --custom-domain-name client1-contoso-com --profile-name FrontDoor01 --host-name client1.contoso.com --minimum-tls-version TLS12 --certificate-type ManagedCertificate --no-wait

 

 

The loop:

 

#! /bin/bash

while IFS="," read -r domainName domainHost
do
	az afd custom-domain create -g rg-test-frontdoor --custom-domain-name $domainName --profile-name FrontDoor01 --host-name $domainHost --minimum-tls-version TLS12 --certificate-type ManagedCertificate --no-wait
	echo "Creating: $domainName, $domain"
	echo ""
done < <(tail -n +2 domains1.csv)

 

And my test CSV:

 

domainName,domainHost
client1-contoso-com,client1.contoso.com
client2-contoso-com,client2.contoso.com

 

Running the above bash script as createDomains.sh I get the following:

 

****@****:/mnt/c/scripts/FrondoorCSV$ ./createdomains.sh
Command group 'afd' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
'. dRequest) Property 'AfdDomain.HostName' cannot be set to 'client1.contoso.com
Code: BadRequest
'. sage: Property 'AfdDomain.HostName' cannot be set to 'client1.contoso.com
Creating: client1-contoso-com, client1.contoso.com

Command group 'afd' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
'. dRequest) Property 'AfdDomain.HostName' cannot be set to 'client2.contoso.com
Code: BadRequest
'. sage: Property 'AfdDomain.HostName' cannot be set to 'client2.contoso.com
Creating: client2-contoso-com, client2.contoso.com

 

 

Any ideas on how can I make it work, or a workaround for this massive job?

 

I'd need something to automate the TXT record to DNS zone but this is in the second plan.

 

Thank you in advance, Will.

  • Hello,WilliamBonomo 

     

    Do you have the same issue when you're launching the command manually?
    Do you have the same bahavior when you're launching the script with only 1 custom domain?

     

    I tried on my side with your script and csv and it works well.
    For your information I used a Standard AFD during my tests

     

     

    Let us know.

    • WilliamBonomo's avatar
      WilliamBonomo
      Brass Contributor
      Hi,

      Thanks for getting back to me.

      Yes if I run the command manually it works fine.

      Same behavior if running with only one customer domain.

      Can I ask you what OS are you using the CLI? I've tried on two different Ubuntu machines.

Resources