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
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.
18
18
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.
20
20
21
21
## Prerequisites
22
22
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
+
23
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
+
37
+
- 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
+
---
43
+
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.
24
47
25
-
## Azure portal
48
+
#[Azure portal](#tab/azureportal)
26
49
27
50
1. Sign in to the [Azure portal](https://portal.azure.com).
28
51
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,145 @@ You can use the [Azure portal](#azure-portal), the [Azure CLI](#azure-cli), or [
36
59
37
60
:::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.":::
38
61
39
-
## Azure CLI
62
+
#[Azure CLI](#tab/azurecli/)
40
63
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.
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.
42
65
43
-
- If using the CLI locally in Bash, sign in to Azure with `az login`.
44
-
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
46
67
47
68
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*.
48
69
49
-
```azurecli-interactive
70
+
```azurecli
71
+
# Dissociate the public IP address from the IP configuration
50
72
az network nic ip-config update \
51
73
--name ipconfigmyVM \
52
74
--resource-group myResourceGroup \
53
75
--nic-name myVMNic \
54
76
--public-ip-address null
55
77
```
56
78
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
58
80
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*:
62
82
63
-
The output includes one or more lines that are similar to the following example:
az vm nic list --vm-name myVM --resource-group myResourceGroup
86
+
```
68
87
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:
70
89
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*:
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*:
84
99
85
-
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
100
+
```azurecli
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
+
```
86
104
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:
88
106
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:
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
114
+
115
+
### Discover name of public IP address
97
116
98
-
In the previous example, *myVMPublicIP* is the name of the public IP address.
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*:
99
118
100
-
## PowerShell
119
+
```azurecli
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:
In the previous example, *myVMPublicIP* is the name of the public IP address.
101
130
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.
131
+
# [Azure PowerShell](#tab/azurepowershell/)
103
132
104
-
- If using PowerShell locally, sign in to Azure with `Connect-AzAccount`.
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.
105
134
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.
135
+
### Dissociate IP address
107
136
108
137
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*.
109
138
110
139
```azurepowershell
140
+
# Dissociate the public IP address from the network interface
- 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
147
+
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*:
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*:
128
167
129
-
In the previous example, *myVMNic* is the name of the network interface.
168
+
```azurepowershell
169
+
# Get the name of the IP configuration for a network interface
- 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*:
174
+
The output includes one or more lines that are similar to the following example:
In the previous example, *ipconfigmyVM* is the name of the IP configuration.
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*:
145
185
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*:
186
+
```azurepowershell
187
+
# Get the name of the public IP address associated to an IP configuration
0 commit comments