Skip to content

Commit c41ac26

Browse files
committed
edits and screenshots
1 parent dcd0a38 commit c41ac26

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed
74.9 KB
Loading
123 KB
Loading
Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: View and Modify Hostnames
2+
title: View and Modify hostnames
33
description: Learn how to view and modify hostnames for your Azure virtual machines by using the Azure portal or a remote connection.
44
services: virtual-network
55
author: asudbring
@@ -12,16 +12,18 @@ ms.date: 03/29/2023
1212
ms.author: allensu
1313
---
1414

15-
# View and modify the hostname
15+
# View and modify hostnames
1616

17-
The hostname identifies your virtual machine in the user interface and Azure operations. You first assign the hostname of a virtual machine in the **Virtual machine name** field during the creation process in the Azure portal. After you create a virtual machine, you can view and modify the hostname either through a remote connection or in the Azure portal.
17+
The hostname identifies your virtual machine (VM) in the user interface and Azure operations. You first assign the hostname of a VM in the **Virtual machine name** field during the creation process in the Azure portal. After you create a VM, you can view and modify the hostname either through a remote connection or in the Azure portal.
1818

1919
## View hostnames
20-
You can view the hostnames of virtual machines and role instances in a cloud service by using any of the following tools.
20+
You can view the hostname of your VM in a cloud service by using any of the following tools.
2121

2222
### Azure portal
2323

24-
You can view the hostname in the Azure portal on the **Properties** page listed under **Computer Name**.
24+
In the Azure portal, go to your VM, and select **Properties** from the left navigation. On the **Properties** page, you can view the hostname under **Computer Name**.
25+
26+
:::image type="content" source="articles\virtual-network\media\virtual-networks-viewing-and-modifying-hostnames\virtual-machine-properties.png" alt-text="Screenshot that shows the Properties page of a virtual machine and highlights the Computer Name.":::
2527

2628
### Remote Desktop
2729
You can connect to your virtual machine using a remote desktop tool like Remote Desktop (Windows), Windows PowerShell remoting (Windows), SSH (Linux and Windows) or Bastion (Azure portal). You can then view the hostname in a few ways:
@@ -34,30 +36,45 @@ You can connect to your virtual machine using a remote desktop tool like Remote
3436
From a REST client, follow these instructions:
3537

3638
1. Ensure that you have an authenticated connection to the Azure portal. Follow the steps presented in [Create an Azure Active Directory application and service principal that can access resources](/azure/active-directory/develop/howto-create-service-principal-portal).
37-
2. Send a request in the following format: `GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2022-11-01`. For more information on GET requests for virtual machines, see [Virtual Machines - Get](/rest/api/compute/virtual-machines/get).
39+
2. Send a request in the following format:
40+
41+
```http
42+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2022-11-01`.
43+
```
44+
45+
For more information on GET requests for virtual machines, see [Virtual Machines - Get](/rest/api/compute/virtual-machines/get).
3846
3. Look for the **osProfile** and then the **computerName** element to find the host name.
3947
4048
> [!WARNING]
41-
> You can also view the internal domain suffix for your cloud service by running ipconfig /all from a command prompt in a remote desktop session (Windows), or by running cat /etc/resolv.conf from an SSH terminal (Linux).
49+
> You can also view the internal domain suffix for your cloud service by running `ipconfig /all` from a command prompt in a remote desktop session (Windows), or by running `cat /etc/resolv.conf` from an SSH terminal (Linux).
4250
>
4351
>
4452
4553
## Modify a hostname
46-
You can modify the hostname for any virtual machine or role instance by renaming the computer from a remote desktop session or by using **Run command** in the Azure portal.
54+
You can modify the hostname for any VM by renaming the computer from a remote desktop session or by using **Run command** in the Azure portal.
55+
56+
From a remote session:
57+
* For Windows, you can change the hostname from PowerShell by using the [Rename-Computer](/powershell/module/microsoft.powershell.management/rename-computer) command.
58+
* For Linux, you can change the hostname by using `hostnamectl`.
4759
48-
* For a Windows virtual, you can change the hostname from PowerShell by using the [Rename-Computer](/powershell/module/microsoft.powershell.management/rename-computer) command. You can also run this command by selecting **RunPowerShellScript** and entering the command in the **Run Command Script** pane.
60+
You can also use run these commands to find the hostname for your VM from the Azure portal by using **Run command**. In the Azure portal, go to your VM, and select **Run command** from the left navigation. From the **Run command** page in the Azure portal:
61+
* For Windows, select **RunPowerShellScript** and use `Rename-Computer` in the **Run Command Script** pane.
62+
* For Linux, select **RunShellScript** and use `hostnamectl` in the **Run Command Script** pane.
4963
50-
* In Linux, you can change the hostname by using `hostnamectl`. You can also run this command by selecting **RunShellScript** and entering the command in the **Run Command Script** pane.
64+
The following image shows shows the **Run command** page in the Azure portal for a Windows VM.
65+
66+
:::image type="content" source="articles\virtual-network\media\virtual-networks-viewing-and-modifying-hostnames\virtual-machine-run-command.png" alt-text="Screenshot that shows the Run command page for a Windows virtual machine and highlights the RunPowerShellScript feature.":::
5167
5268
## Azure classic deployment model
5369
54-
The Azure classic deployment model uses a configuration file that you can download and upload to change the host name. To allow your host name to reference your role instances, you must set the value for the host name in the service configuration file for each role. You do that by adding the desired host name to the **vmName** attribute of the **Role** element. The value of the **vmName** attribute is used as a base for the host name of each role instance. For example, if **vmName** is *webrole* and there are three instances of that role, the host names of the instances are *webrole0*, *webrole1*, and *webrole2*. You don't need to specify a host name for virtual machines in the configuration file, because the host name for a virtual machine is populated based on the virtual machine name. For more information about configuring a Microsoft Azure service, see [Azure Service Configuration Schema (.cscfg File)](/previous-versions/azure/reference/ee758710(v=azure.100))
70+
The Azure classic deployment model uses a configuration file that you can download and upload to change the host name. To allow your host name to reference your role instances, you must set the value for the host name in the service configuration file for each role. You do that by adding the desired host name to the **vmName** attribute of the **Role** element. The value of the **vmName** attribute is used as a base for the host name of each role instance.
71+
72+
For example, if **vmName** is *webrole* and there are three instances of that role, the host names of the instances are *webrole0*, *webrole1*, and *webrole2*. You don't need to specify a host name for virtual machines in the configuration file, because the host name for a virtual machine is populated based on the virtual machine name. For more information about configuring a Microsoft Azure service, see [Azure Service Configuration Schema (.cscfg File)](/previous-versions/azure/reference/ee758710(v=azure.100))
5573
5674
### Service configuration file
57-
You can download the service configuration file for a deployed service from the **Configure** pane of the service in the Azure portal. You can then look for the **vmName** attribute for the **Role name** element to see the host name. Keep in mind that this host name is used as a base for the host name of each role instance. For example, if **vmName** is *webrole* and there are three instances of that role, the host names of the instances are *webrole0*, *webrole1*, and *webrole2*. For more information, see [Azure Virtual Network Configuration Schema](/previous-versions/azure/reference/jj157100(v=azure.100))
75+
In the Azure classic deployment model, you can download the service configuration file for a deployed service from the **Configure** pane of the service in the Azure portal. You can then look for the **vmName** attribute for the **Role name** element to see the host name. Keep in mind that this host name is used as a base for the host name of each role instance. For example, if **vmName** is *webrole* and there are three instances of that role, the host names of the instances are *webrole0*, *webrole1*, and *webrole2*. For more information, see [Azure Virtual Network Configuration Schema](/previous-versions/azure/reference/jj157100(v=azure.100))
5876
5977
6078
## Next steps
61-
[Name Resolution (DNS)](virtual-networks-name-resolution-for-vms-and-role-instances.md)
62-
63-
[Specify DNS settings using network configuration files](/previous-versions/azure/virtual-network/virtual-networks-specifying-a-dns-settings-in-a-virtual-network-configuration-file)
79+
* [Name Resolution (DNS)](virtual-networks-name-resolution-for-vms-and-role-instances.md)
80+
* [Specify DNS settings using network configuration files](/previous-versions/azure/virtual-network/virtual-networks-specifying-a-dns-settings-in-a-virtual-network-configuration-file)

0 commit comments

Comments
 (0)