What DNS Name Label should I give my Azure Virtual Machine?
Asked Answered
S

3

5

In my ongoing effort to wrap my head around Azure's new Resource Group model (see previous questions here and here), I am now trying to create a new Virtual Machine that will be used as a web server.

I have thee questions:

Question One:

Assuming I eventually want this VM to host the website woodswild.com, what DNS Name Label should I give this VM? Does it matter? All I know for sure is that it needs to be globally unique. Does it need to reflect the domain I want to host (woodswild.com)?

Question Two:

Do I even need to set the DNS name at all?

Question Three:

And, now that I've already created it, can I still change the DNS Name Label from "none" to something? And if so, how?

enter image description here

Stedman answered 5/2, 2016 at 17:1 Comment(0)
R
5

There is no requirement at all to either have a DNS name, or to have one that is anything to do with what you are setting up. I have a script that I use that creates one from a GUID!

This follows the usual process of assigning a setting to Azure.

  1. Get-something, assign it to a variable.
  2. Change a property of that variable, by assigning some other value.
  3. Write the change to Azure using the Set-something cmdlet.

in this case it is a little complicated since the ultimate structure we want looks like this

"dnsSettings": {
   "domainNameLabel": "mytestdnsname",
   "fqdn": "mytestdnsname.westeurope.cloudapp.azure.com"
  }

Presuming we created a PIP like this

New-AzureRmPublicIpAddress -Name test01PIP -ResourceGroupName test -AllocationMethod Dynamic -Location westeurope  

The fully qualified domain name is set automatically, so we just need to set the DomainNameLabel which we do like this,

$ip = Get-AzureRmPublicIpAddress -Name test01PIP -ResourceGroupName test01[1] 
$ip.DnsSettings += @{DomainNameLabel = "mytestdnsname"}                   [2]
Set-AzureRmPublicIpAddress -PublicIpAddress $ip                           [3]
Raffle answered 5/2, 2016 at 18:21 Comment(0)
W
2

The name does not matter for your future planing to run a website on it. At this point you can use it to access the machine yourself. And in the end the machine will endup behind a loadbalancer. So the name is only for your internal use to find it beside it ip address.

Weinstein answered 5/2, 2016 at 17:13 Comment(1)
ok thanks! Do I need a DNS name at all? And if so, how do I set it now that the VM is created?Stedman
R
0

To answer part Two of the question:

You don't need to set a DNS name at all, you can just use the IP address if your application allows. But if you are using a Dynamic address, it is convenient to set a DomainNameLabel here -- you can point at it with a CNAME from your own zone to catch any changes. (You can also make an A record in an Azure-hosted DNS Zone that automatically points at the Public IP, but if not hosted in Azure, CNAME is the way to go).

The Catch 22 is that you need to come up with the DNS label (first component) yourself but it has to be unique among all Public IPs in the zone (zones like northeurope.cloudapp.azure.com) -- even those of other users. I have a use case where I only need a PTR record for the IP -- I can set that with a reverseFqdn attribute, but I still have to come up with a unique domainNameLabel as well. (And I actually managed to get a uniqueness conflict because someone else with the same cookbook had k8stest.northeurope.cloudapp.azure.com allocated at the same time).

Raama answered 31/5, 2021 at 7:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.