I'm trying to write a domain management portal and to map a domain to an Azure webapp I need to add a TXT record with the app's ASUID to the domain. The only way I can find to get the ASUID is through the Azure Portal dashboard. Is there an API I can use to get it programmatically?
In case you get here wondering how to do this without manual intervention. This is my work flow:
if ($ex -Match "TXT record")
. If it's a hit I grab the asuid as below. If not I throw an exception.Install-Module -Name Az.ResourceGraph
. Note that only the host name binding failed so the app service is there. You can now run a query to get the value you need:
$asuid = Search-AzGraph -Query "Resources | project name, properties.customDomainVerificationId, type | where type == 'microsoft.web/sites'" | where {$_.name -eq "my-webapp-name"}
PS. If you are using the CLI and not PowerShell you can still do this using the CLI extension: az extension add --name resource-graph