Change Azure VM Network Interface DNS Configuration from Custom to Inherit from virtual network

JordanP 1 Reputation point
2020-07-20T20:38:25.197+00:00

I couldn't find an answer for that yet.

I will explain:

Today we have some Azure VMs using custom DNS configuration instead of Vnet heritage and we would like to use the second option, but we 'd like powershell to force this change for 60 Vms, otherwise we must apply this manually.

Could some one help me please?

Thank you

Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
777 questions
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GitaraniSharma-MSFT 50,096 Reputation points Microsoft Employee Moderator
    2020-07-21T13:12:44.367+00:00

    Hello @JordanP ,

    You can use the "Set-AzNetworkInterface" PowerShell commandlet to change DNS settings on a network interface.
    Please refer : https://learn.microsoft.com/en-us/powershell/module/az.network/set-aznetworkinterface?view=azps-4.4.0#description

    NOTE : The second command adds DNS server 192.168.1.100 to this interface. To remove a DNS server, follow the commands listed above, but replace ".Add" with ".Remove" in the second command. This will remove the custom DNS server from the interface and revert the DNS server setting to "Inherit from virtual network".

    Or you can use the Azure CLI "az network nic update" cmdlet.
    Please refer : https://learn.microsoft.com/en-us/cli/azure/network/nic?view=azure-cli-latest#az-network-nic-update

    Hope this helps!

    Kindly let us know if the above helps or you need further assistance on this issue.

    ----------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer" wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.