Skip to content

Commit 11b7f39

Browse files
Implemented the required validation
1 parent 8bc5dbc commit 11b7f39

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Deployment/resourcedeployment.ps1

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,33 @@ try {
605605
# 6-2. Generate Unique backend API fqdn Name - esgdocanalysis-3 digit random number with padding 0
606606
$dnsName = "kmgs$($(Get-Random -Minimum 0 -Maximum 9999).ToString("D4"))"
607607

608+
# Validate if the resource group name, public IP name and dns name are provided
609+
if ([string]::IsNullOrEmpty($aksResourceGroupName)) {
610+
Write-Host "Error: Resource Group name is null or empty." -ForegroundColor Red
611+
exit 1 # Exit the script if the resource group name is missing
612+
}
613+
if ([string]::IsNullOrEmpty($publicIpName)) {
614+
Write-Host "Error: Public IP name is null or empty." -ForegroundColor Red
615+
exit 1 # Exit the script if the public IP name is missing
616+
}
617+
if ([string]::IsNullOrEmpty($dnsName)) {
618+
Write-Host "Error: DNS name is null or empty." -ForegroundColor Red
619+
exit 1 # Exit the script if the dns name is missing
620+
}
608621
# 6-3. Assign DNS Name to the public IP address
609622
az network public-ip update --resource-group $aksResourceGroupName --name $publicIpName --dns-name $dnsName
610-
# 6-4. Get FQDN for the public IP address
611-
$fqdn = az network public-ip show --resource-group $aksResourceGroupName --name $publicIpName --query "dnsSettings.fqdn" --output tsv
612-
Write-Host "FQDN for the public IP address is: $fqdn" -ForegroundColor Green
613623

624+
# 6-4. Get FQDN for the public IP address
625+
$fqdn = az network public-ip show --resource-group $aksResourceGroupName --name $publicIpName --query "dnsSettings.fqdn" --output tsv
626+
627+
# Validate if the FQDN is null or empty
628+
if ([string]::IsNullOrEmpty($fqdn)) {
629+
Write-Host "No FQDN is associated with the public IP address." -ForegroundColor Red
630+
Exit 1
631+
} else {
632+
Write-Host "FQDN for the public IP address is: $fqdn" -ForegroundColor Green
633+
}
634+
614635
# 7. Assign the role for aks system assigned managed identity to App Configuration Data Reader role with the scope of Resourcegroup
615636
Write-Host "Assign the role for aks system assigned managed identity to App Configuration Data Reader role" -ForegroundColor Green
616637
# Get vmss resource group name

0 commit comments

Comments
 (0)