You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Dissociate a public IP address from an Azure VM
3
3
titlesuffix: Azure Virtual Network
4
-
description: Learn how to dissociate a public IP address from a VM
4
+
description: Learn how to dissociate a public IP address from an Azure virtual machine (VM) using the Azure portal, Azure CLI or Azure PowerShell.
5
5
services: virtual-network
6
-
documentationcenter: ''
7
6
author: asudbring
8
7
ms.service: virtual-network
9
8
ms.subservice: ip-services
10
9
ms.topic: how-to
11
-
ms.tgt_pltfrm: na
12
10
ms.workload: infrastructure-services
13
-
ms.date: 12/04/2019
11
+
ms.date: 12/16/2022
14
12
ms.author: allensu
15
-
13
+
ms.custom: template-how-to, engagement-fy23
16
14
---
17
15
18
16
# Dissociate a public IP address from an Azure VM
@@ -21,103 +19,153 @@ In this article, you learn how to dissociate a public IP address from an Azure v
21
19
22
20
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.
23
21
22
+
## Prerequisites
23
+
24
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
25
+
24
26
## Azure portal
25
27
26
28
1. Sign in to the [Azure portal](https://portal.azure.com).
27
29
2. Browse to, or search for the virtual machine that you want to disassociate the public IP address from and then select it.
28
-
3. In the VM page, select **Overview**, select the public IP address as shown in the following picture:
30
+
3. In the VM page, select **Overview**, and then select the public IP address.
29
31
30
-

32
+
:::image type="content" source="./media/remove-public-ip-address-vm/vm-public-ip.png" alt-text="Screenshot of the Overview page of a virtual machine showing of the public IP.":::
31
33
32
-
4. In the public IP address page, select **Overview**, and then select **Dissociate**, as shown in the following picture:
33
-
34
-

34
+
4. In the public IP address page, select **Overview**, and then select **Dissociate**.
35
35
36
36
5. In **Dissociate public IP address**, select **Yes**.
37
37
38
+
:::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.":::
39
+
38
40
## Azure CLI
39
41
40
-
Install the [Azure CLI](/cli/azure/install-azure-cli?toc=%2fazure%2fvirtual-network%2ftoc.json), or use the Azure Cloud Shell. The Azure Cloud Shell is a free Bash shell that you can run directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account. Select the **Try it** button in the CLI commands that follow. Selecting **Try it** invokes a Cloud Shell that you can sign in to your Azure account with.
42
+
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.
41
43
42
-
1. If using the CLI locally in Bash, sign in to Azure with `az login`.
43
-
2. 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. The following example dissociates a public IP address named *myVMPublicIP* from the IP configuration named *ipconfigmyVM* of an existing network interface named *myVMVMNic* that is attached to a VM named *myVM* in a resource group named *myResourceGroup*.
44
-
45
-
```azurecli-interactive
46
-
az network nic ip-config update \
47
-
--name ipconfigmyVM \
48
-
--resource-group myResourceGroup \
49
-
--nic-name myVMVMNic \
50
-
--remove PublicIpAddress
51
-
```
44
+
- If using the CLI locally in Bash, sign in to Azure with `az login`.
52
45
53
-
If you don't know the name of a 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*:
46
+
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.
54
47
55
-
```azurecli-interactive
56
-
az vm nic list --vm-name myVM --resource-group myResourceGroup
57
-
```
48
+
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*.
49
+
50
+
```azurecli-interactive
51
+
az network nic ip-config update \
52
+
--name ipconfigmyVM \
53
+
--resource-group myResourceGroup \
54
+
--nic-name myVMNic \
55
+
--public-ip-address ''
56
+
```
57
+
58
+
- 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*:
59
+
60
+
```azurecli-interactive
61
+
az vm nic list --vm-name myVM --resource-group myResourceGroup
62
+
```
58
63
59
-
The output includes one or more lines that are similar to the following example:
64
+
The output includes one or more lines that are similar to the following example:
In the previous example, *myVMVic* is the name of the network interface.
64
71
65
-
In the previous example, *myVMVMNic* is the name of the network interface.
72
+
- 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*:
66
73
67
-
- If you don't know the name of an IP configuration for 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 public IP configurations for a network interface named *myVMVMNic* in a resource group named *myResourceGroup*:
74
+
```azurecli-interactive
75
+
az network nic ip-config list --nic-name myVMNic --resource-group myResourceGroup --out table
76
+
```
68
77
69
-
```azurecli-interactive
70
-
az network nic ip-config list --nic-name myVMVMNic --resource-group myResourceGroup --out table
71
-
```
78
+
The output is similar to the following example:
72
79
73
-
- If you don't know the name of a public IP configuration for a network interface, 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 configurations for a network interface named *myVMVMNic* in a resource group named *myResourceGroup*:
80
+
```
81
+
Name Primary PrivateIpAddress PrivateIpAddressVersion PrivateIpAllocationMethod ProvisioningState ResourceGroup
az network nic ip-config show --name ipconfigmyVM --nic-name myVMVMNic --resource-group myResourceGroup --query publicIPAddress.id
77
-
```
86
+
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
78
87
88
+
- 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*:
89
+
90
+
```azurecli-interactive
91
+
az network nic ip-config show --name ipconfigmyVM --nic-name myVMNic --resource-group myResourceGroup --query publicIpAddress.id
92
+
```
93
+
The output includes one or more lines that are similar to the following example:
In the previous example, *myVMPublicIP* is the name of the public IP address.
79
100
80
101
## PowerShell
81
102
82
-
Install [PowerShell](/powershell/azure/install-az-ps), or use the Azure Cloud Shell. 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. Select the **Try it** button in the PowerShell commands that follow. Selecting **Try it** invokes a Cloud Shell that you can sign in to your Azure account with.
103
+
Install [PowerShell](/powershell/azure/install-az-ps), 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.
83
104
84
-
1. If using PowerShell locally, sign in to Azure with `Connect-AzAccount`.
85
-
2. 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.
105
+
- If using PowerShell locally, sign in to Azure with `Connect-AzAccount`.
86
106
87
-
The following example dissociates a public IP address named *myVMPublicIP* from a network interface named *myVMVMNic* that is attached to a VM named *myVM*. All resources are in a resource group named *myResourceGroup*.
107
+
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.
108
+
109
+
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*.
- If you don't know the name of a 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*:
117
+
- 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*:
The output includes one or more lines that are similar to the example that follows. In the example output, *myVMVMNic* is the name of the network interface.
The output includes one or more lines that are similar to the following example:
107
125
108
-
- 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 *myVMVMNic* in a resource group named *myResourceGroup*:
In the previous example, *myVMNic* is the name of the network interface.
114
131
115
-
The output includes one or more lines that are similar to the example that follows. In the example output, *ipconfigmyVM* is the name of an IP configuration.
- 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*:
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
146
+
147
+
- 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*:
0 commit comments