Skip to content

Commit 8370649

Browse files
committed
updated tabs + Acrolinx
1 parent 68a748a commit 8370649

File tree

1 file changed

+117
-75
lines changed

1 file changed

+117
-75
lines changed

articles/virtual-network/ip-services/remove-public-ip-address-vm.md

Lines changed: 117 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to dissociate a public IP address from an Azure virtual m
55
services: virtual-network
66
author: mbender-ms
77
ms.author: mbender
8-
ms.date: 08/24/2023
8+
ms.date: 11/19/2024
99
ms.service: azure-virtual-network
1010
ms.subservice: ip-services
1111
ms.topic: how-to
@@ -14,15 +14,38 @@ ms.custom: template-how-to, engagement-fy23, devx-track-azurepowershell, devx-tr
1414

1515
# Dissociate a public IP address from an Azure VM
1616

17-
In this article, you learn how to dissociate a public IP address from an Azure virtual machine (VM). Removing the public IP address of your VM will also remove its ability to connect to the internet.
17+
In this article, you learn how to dissociate a public IP address from an Azure virtual machine (VM). Removing the public IP address of your VM removes access to the Internet.
1818

19-
You can use the [Azure portal](#azure-portal), the [Azure CLI](#azure-cli), or [Azure PowerShell](#powershell) to dissociate a public IP address from a VM.
19+
You can use the Azure portal, the Azure CLI, or Azure PowerShell to dissociate a public IP address from a VM.
2020

2121
## Prerequisites
2222

23+
# [Azure portal](#tab/azureportal)
24+
25+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
26+
- A virtual machine with a public IP address associated to it.
27+
28+
# [Azure CLI](#tab/azurecli/)
29+
30+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
31+
- A virtual machine with a public IP address associated to it.
32+
- Install the [Azure CLI](/cli/azure/install-azure-cli), or use the [Azure Cloud Shell](../../cloud-shell/overview.md). The Azure Cloud Shell is a free shell that you can run directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account.
33+
- If using the CLI locally in Bash, sign in to Azure with `az login`.
34+
35+
# [Azure PowerShell](#tab/azurepowershell/)
36+
2337
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
38+
- A virtual machine with a public IP address associated to it.
39+
- Install [PowerShell](/powershell/azure/install-azure-powershell), or use the [Azure Cloud Shell](../../cloud-shell/overview.md). The Azure Cloud Shell is a free shell that you can run directly within the Azure portal. It has PowerShell preinstalled and configured to use with your account.
40+
- If using PowerShell locally, sign in to Azure with `Connect-AzAccount`.
41+
42+
---
2443

25-
## Azure portal
44+
## Dissociate a public IP address from a VM
45+
46+
In this step, you dissociate a public IP address from a virtual machine using the Azure portal, Azure CLI, or Azure PowerShell. The IP address is associated to an IP configuration of a network interface attached to the VM.
47+
48+
# [Azure portal](#tab/azureportal)
2649

2750
1. Sign in to the [Azure portal](https://portal.azure.com).
2851
2. Browse to, or search for the virtual machine that you want to disassociate the public IP address from and then select it.
@@ -36,127 +59,146 @@ You can use the [Azure portal](#azure-portal), the [Azure CLI](#azure-cli), or [
3659

3760
:::image type="content" source="./media/remove-public-ip-address-vm/dissociate-public-ip.png" alt-text="Screenshot of the Overview page of a public IP address resource showing how to dissociate it from the network interface of a virtual machine.":::
3861

39-
## Azure CLI
40-
41-
Install the [Azure CLI](/cli/azure/install-azure-cli), or use the [Azure Cloud Shell](../../cloud-shell/overview.md). The Azure Cloud Shell is a free shell that you can run directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account.
62+
# [Azure CLI](#tab/azurecli/)
4263

43-
- If using the CLI locally in Bash, sign in to Azure with `az login`.
64+
In this task, you use the [az network nic-ip-config update](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-update) command to dissociate a public IP address from an IP configuration.
4465

45-
A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the [az network nic-ip-config update](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-update) command to dissociate a public IP address from an IP configuration.
66+
### Dissociate IP address
4667

4768
The following example dissociates a public IP address named *myVMPublicIP* from an IP configuration named *ipconfigmyVM* of an existing network interface named *myVMNic* that is attached to a VM named *myVM* in a resource group named *myResourceGroup*.
4869

4970
```azurecli-interactive
71+
# Dissociate the public IP address from the IP configuration
5072
az network nic ip-config update \
5173
--name ipconfigmyVM \
5274
--resource-group myResourceGroup \
5375
--nic-name myVMNic \
5476
--public-ip-address null
5577
```
5678

57-
- If you don't know the name of the network interface attached to your VM, use the [az vm nic list](/cli/azure/vm/nic#az-vm-nic-list) command to view them. For example, the following command lists the names of the network interfaces attached to a VM named *myVM* in a resource group named *myResourceGroup*:
79+
### Discover name of network interface
5880

59-
```azurecli-interactive
60-
az vm nic list --vm-name myVM --resource-group myResourceGroup
61-
```
81+
If you don't know the name of the network interface attached to your VM, use the [az vm nic list](/cli/azure/vm/nic#az-vm-nic-list) command to view them. For example, the following command lists the names of the network interfaces attached to a VM named *myVM* in a resource group named *myResourceGroup*:
6282

63-
The output includes one or more lines that are similar to the following example:
64-
65-
```
66-
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic",
67-
```
83+
```azurecli-interactive
84+
# List the network interfaces attached to a VM
85+
az vm nic list --vm-name myVM --resource-group myResourceGroup
86+
```
6887

69-
In the previous example, *myVMVic* is the name of the network interface.
88+
The output includes one or more lines that are similar to the following example:
7089

71-
- If you don't know the name of the IP configuration of a network interface, use the [az network nic ip-config list](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-list) command to retrieve them. For example, the following command lists the names of the IP configurations for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
90+
```
91+
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic",
92+
```
7293

73-
```azurecli-interactive
74-
az network nic ip-config list --nic-name myVMNic --resource-group myResourceGroup --out table
75-
```
94+
In the previous example, *myVMVic* is the name of the network interface.
7695

77-
The output is similar to the following example:
96+
### Discover name of IP configuration
7897

79-
```
80-
Name Primary PrivateIpAddress PrivateIpAddressVersion PrivateIpAllocationMethod ProvisioningState ResourceGroup
81-
------------ --------- ------------------ ------------------------- --------------------------- ------------------- ---------------
82-
ipconfigmyVM True 10.0.0.4 IPv4 Dynamic Succeeded myResourceGroup
83-
```
98+
If you don't know the name of the IP configuration of a network interface, use the [az network nic ip-config list](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-list) command to retrieve them. For example, the following command lists the names of the IP configurations for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
8499

85-
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
100+
```azurecli-interactive
101+
# List the IP configurations of a network interface
102+
az network nic ip-config list --nic-name myVMNic --resource-group myResourceGroup --out table
103+
```
86104

87-
- If you don't know the name of the public IP address associated to an IP configuration, use the [az network nic ip-config show](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-show) command to retrieve them. For example, the following command lists the names of the public IP addresses for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
105+
The output is similar to the following example:
88106

89-
```azurecli-interactive
90-
az network nic ip-config show --name ipconfigmyVM --nic-name myVMNic --resource-group myResourceGroup --query publicIpAddress.id
91-
```
92-
The output includes one or more lines that are similar to the following example:
93-
94-
```
95-
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myVMPublicIP",
96-
```
107+
```
108+
Name Primary PrivateIpAddress PrivateIpAddressVersion PrivateIpAllocationMethod ProvisioningState ResourceGroup
109+
------------ --------- ------------------ ------------------------- --------------------------- ------------------- ---------------
110+
ipconfigmyVM True 10.0.0.4 IPv4 Dynamic Succeeded myResourceGroup
111+
```
112+
113+
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
97114

98-
In the previous example, *myVMPublicIP* is the name of the public IP address.
115+
### Discover name of public IP address
99116

100-
## PowerShell
117+
If you don't know the name of the public IP address associated to an IP configuration, use the [az network nic ip-config show](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-show) command to retrieve them. For example, the following command lists the names of the public IP addresses for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
101118

102-
Install [PowerShell](/powershell/azure/install-azure-powershell), or use the [Azure Cloud Shell](../../cloud-shell/overview.md). The Azure Cloud Shell is a free shell that you can run directly within the Azure portal. It has PowerShell preinstalled and configured to use with your account.
119+
```azurecli-interactive
120+
# Get the name of public IP address associated to an IP configuration
121+
az network nic ip-config show --name ipconfigmyVM --nic-name myVMNic --resource-group myResourceGroup --query publicIpAddress.id
122+
```
123+
The output includes one or more lines that are similar to the following example:
124+
125+
```
126+
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myVMPublicIP",
127+
```
128+
129+
In the previous example, *myVMPublicIP* is the name of the public IP address.
103130

104-
- If using PowerShell locally, sign in to Azure with `Connect-AzAccount`.
131+
# [Azure PowerShell](#tab/azurepowershell/)
105132

106-
A public IP address is associated to an IP configuration of a network interface attached to a VM. Use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to get a network interface. Set the Public IP address value to null and then use the [Set-AzNetworkInterface](/powershell/module/Az.Network/Set-AzNetworkInterface) command to write the new IP configuration to the network interface.
133+
In this task, you use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to get a network interface. Set the Public IP address value to null and then use the [Set-AzNetworkInterface](/powershell/module/Az.Network/Set-AzNetworkInterface) command to write the new IP configuration to the network interface.
134+
135+
### Dissociate IP address
107136

108137
The following example dissociates a public IP address named *myVMPublicIP* from a network interface named *myVMNic* that is attached to a VM named *myVM*. All resources are in a resource group named *myResourceGroup*.
109138

110139
```azurepowershell
140+
# Dissociate the public IP address from the network interface
111141
$nic = Get-AzNetworkInterface -Name myVMNic -ResourceGroup myResourceGroup
112142
$nic.IpConfigurations[0].PublicIpAddress = $null
113143
Set-AzNetworkInterface -NetworkInterface $nic
114144
```
115145

116-
- If you don't know the name of the network interface attached to your VM, use the [Get-AzVM](/powershell/module/Az.Compute/Get-AzVM) command to view them. For example, the following command lists the names of the network interfaces attached to a VM named *myVM* in a resource group named *myResourceGroup*:
146+
### Discover name of network interface
117147

118-
```azurepowershell
119-
$vm = Get-AzVM -name myVM -ResourceGroupName myResourceGroup
120-
$vm.NetworkProfile
121-
```
148+
If you don't know the name of the network interface attached to your VM, use the [Get-AzVM](/powershell/module/Az.Compute/Get-AzVM) command to view them. For example, the following command lists the names of the network interfaces attached to a VM named *myVM* in a resource group named *myResourceGroup*:
122149

123-
The output includes one or more lines that are similar to the following example:
150+
```azurepowershell
151+
# Get the network interface attached to a VM
152+
$vm = Get-AzVM -name myVM -ResourceGroupName myResourceGroup
153+
$vm.NetworkProfile
154+
```
124155

125-
```
126-
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic",
127-
```
156+
The output includes one or more lines that are similar to the following example:
128157

129-
In the previous example, *myVMNic* is the name of the network interface.
158+
```
159+
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic",
160+
```
130161

131-
- If you don't know the name of an IP configuration for a network interface, use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to retrieve them. For example, the following command lists the names of the IP configurations for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
162+
In the previous example, *myVMNic* is the name of the network interface.
132163

133-
```azurepowershell-interactive
134-
$nic = Get-AzNetworkInterface -Name myVMNic -ResourceGroupName myResourceGroup
135-
$nic.IPConfigurations.Id
136-
```
164+
### Discover name of IP configuration
137165

138-
The output includes one or more lines that are similar to the following example:
166+
If you don't know the name of an IP configuration for a network interface, use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to retrieve them. For example, the following command lists the names of the IP configurations for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
139167

140-
```
141-
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic/ipConfigurations/ipconfigmyVM"
142-
```
168+
```azurepowershell-interactive
169+
# Get the name of the IP configuration for a network interface
170+
$nic = Get-AzNetworkInterface -Name myVMNic -ResourceGroupName myResourceGroup
171+
$nic.IPConfigurations.Id
172+
```
143173

144-
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
174+
The output includes one or more lines that are similar to the following example:
145175

146-
- If you don't know the name of the public IP address associated to an IP configuration, use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to retrieve them. For example, the following command lists the name of the public IP addresses for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
176+
```
177+
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/myVMNic/ipConfigurations/ipconfigmyVM"
178+
```
179+
180+
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
147181

148-
```azurepowershell-interactive
149-
$nic = Get-AzNetworkInterface -Name myVMNic -ResourceGroupName myResourceGroup
150-
$nic.IPConfigurations.PublicIpAddress.Id
151-
```
182+
### Discover name of public IP address
183+
184+
If you don't know the name of the public IP address associated to an IP configuration, use the [Get-AzNetworkInterface](/powershell/module/Az.Network/Get-AzNetworkInterface) command to retrieve them. For example, the following command lists the name of the public IP addresses for a network interface named *myVMNic* in a resource group named *myResourceGroup*:
185+
186+
```azurepowershell-interactive
187+
# Get the name of the public IP address associated to an IP configuration
188+
$nic = Get-AzNetworkInterface -Name myVMNic -ResourceGroupName myResourceGroup
189+
$nic.IPConfigurations.PublicIpAddress.Id
190+
```
152191

153-
The output includes one or more lines that are similar to the following example:
192+
The output includes one or more lines that are similar to the following example:
154193

155-
```
156-
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIP"
157-
```
194+
```
195+
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIP"
196+
```
197+
198+
In the previous example, *myVMPublicIP* is the name of the public IP address.
199+
200+
---
158201

159-
In the previous example, *myVMPublicIP* is the name of the public IP address.
160202
## Next steps
161203

162204
In this article, you learned how to dissociate a public IP address from a virtual machine.
@@ -165,4 +207,4 @@ In this article, you learned how to dissociate a public IP address from a virtua
165207

166208
- Learn how to [associate a public IP address to a VM](./associate-public-ip-address-vm.md).
167209

168-
- Learn how to [configure IP addresses for an Azure network interface](./virtual-network-network-interface-addresses.md).
210+
- Learn how to [configure IP addresses for an Azure network interface](./virtual-network-network-interface-addresses.md).

0 commit comments

Comments
 (0)