Tuesday, 4 June 2024

Azure App Service Domain Renewals

Wasn't the easiest thing to export the renewal status for Azure App Service Domains, for use in a report. So I used a bit of Powershell to extract and concatenate it into one variable. The results are combined in variable $ResultsTableArray, which can then be used for reporting. I only need the two fields of name and renewal status, you can add more if you need it!

$ResourceGroup= "<insert your resource group for domains here>"

$JSON_PATH="<insert the full path to a folder you want to use as a working area>"

Get-AzResource -ResourceGroupName "$ResourceGroup" -ResourceType "Microsoft.DomainRegistration/domains" | ForEach-Object {
    $JSON_FILE_PATH="$JSON_PATH/$($_.Name).json"
    Export-AzResourceGroup -ResourceGroupName $_.ResourceGroupName -Resource $_.ResourceId -Path "$JSON_FILE_PATH" | Out-Null
    $DNS_JSON = Get-Content "$JSON_FILE_PATH" | ConvertFrom-Json
    [void]$ResultsTableArray.Add("$($_.Name),$($DNS_JSON.resources.properties.autoRenew)")
    Remove-Item "$JSON_FILE_PATH" -Force | Out-Null
}

No comments:

Post a Comment