azureazure-powershellazure-private-dns

Azure Private DNS Zone Query - PowerShell


The command to create Azure Private Dns zone iss as below :

'''$dnszone = New-AzPrivateDnsZone -ResourceGroupName “Test” -Name “privatelink.database.windows.net”'''

the name parameter value "privatelink.database.windows.net" we need to type manually.

How can we autofetch it or auto create it based on the object for which we are creating Private End Point ??


Solution

  • You can use it like this:

    $sqlserverFQDN = (Get-AzResource -ResourceType "Microsoft.Sql/servers" -Name $serverName -ResourceGroupName $rgName ).Properties.fullyQualifiedDomainName
    
    $result= $sqlserverFQDN -replace "$serverName","privatelink"
    
    echo $result
    

    enter image description here