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: Create a VM with a static public IP address - Azure portal
3
3
description: Learn how to create a VM with a static public IP address using the Azure portal.
4
4
services: virtual-network
5
-
ms.date: 08/24/2023
5
+
ms.date: 11/14/2024
6
6
ms.author: mbender
7
7
author: mbender-ms
8
8
ms.service: azure-virtual-network
9
9
ms.subservice: ip-services
10
10
ms.topic: how-to
11
-
ms.custom: template-how-to, engagement-fy23
11
+
ms.custom: template-how-to
12
12
---
13
13
# Create a virtual machine with a static public IP address using the Azure portal
14
14
15
-
In this article, you'll create a virtual machine (VM) with a static public IP address. A public IP address enables you to communicate to a VM from the internet. Assign a static public IP address, rather than a dynamic address, to ensure the address never changes.
15
+
In this article, you create a virtual machine (VM) with a static public IP address. A public IP address enables you to communicate to a VM from the internet. Assign a static public IP address, rather than a dynamic address, to ensure the address never changes.
16
16
17
17
Public IP addresses have a [nominal charge](https://azure.microsoft.com/pricing/details/ip-addresses). There's a [limit](../../azure-resource-manager/management/azure-subscription-service-limits.md?toc=%2fazure%2fvirtual-network%2ftoc.json#azure-resource-manager-virtual-networking-limits) to the number of public IP addresses that you can use per subscription.
18
18
19
19
You can download the list of ranges (prefixes) for the Azure [Public](https://www.microsoft.com/download/details.aspx?id=56519), [US government](https://www.microsoft.com/download/details.aspx?id=57063), [China](https://www.microsoft.com/download/details.aspx?id=57062), and [Germany](https://www.microsoft.com/download/details.aspx?id=57064) clouds.
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
23
+
## Create a virtual machine with a static public IP address
24
24
25
-
## Sign in to Azure
25
+
In this section, you create a virtual machine with a static public IP address using the Azure portal, Azure PowerShell, or Azure CLI. Along with the virtual machine, you create a public IP address and the other required resources.
26
+
27
+
# [Azure portal](#tab/azureportal)
28
+
29
+
### Sign in to Azure
26
30
27
31
Sign in to the [Azure portal](https://portal.azure.com).
28
32
29
-
## Create a virtual machine
33
+
###Create a virtual machine
30
34
31
35
1. In the search box at the top of the portal, enter *Virtual machine*.
32
36
@@ -40,7 +44,7 @@ Sign in to the [Azure portal](https://portal.azure.com).
40
44
| ------- | ------ |
41
45
|**Project Details**||
42
46
| Subscription | Select your Azure subscription |
43
-
| Resource Group | Select **Create new**.</br> In **Name**, enter *myResourceGroup*.</br> Select **OK**. |
47
+
| Resource Group | Select **Create new**.</br> In **Name**, enter *myResourceGroup*.</br> Select **OK**. |
44
48
|**Instance details**||
45
49
| Virtual machine name | Enter *myVM*. |
46
50
| Region | Select **East US**. |
@@ -56,7 +60,7 @@ Sign in to the [Azure portal](https://portal.azure.com).
56
60
| Select inbound ports | Select **RDP (3389)**. |
57
61
58
62
> [!WARNING]
59
-
> Port 3389 is selected to enable remote access to the Windows Server virtual machine from the internet. Opening port 3389 to the internet is not recommended to manage production workloads.</br> For secure access to Azure virtual machines, see **[What is Azure Bastion?](../../bastion/bastion-overview.md)**
63
+
> Port 3389 is selected to enable remote access to the Windows Server virtual machine from the internet. Opening port 3389 to the internet is not recommended to manage production workloads.</br> For secure access to Azure virtual machines, see **[What is Azure Bastion?](../../bastion/bastion-overview.md)**
60
64
61
65
5. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**.
62
66
@@ -67,7 +71,7 @@ Sign in to the [Azure portal](https://portal.azure.com).
67
71
|**Network interface**||
68
72
| Virtual network | Accept the default network name. |
69
73
| Subnet | Accept the default subnet configuration. |
70
-
| Public IP | Select **Create new**.</br> In **Create public IP address**, enter *myPublicIP* in **Name** . </br> **SKU**: select **Standard**.</br> **Assignment**: select **Static**.</br> Select **OK**.|
74
+
| Public IP | Select **Create new**.</br> In **Create public IP address**, enter *myPublicIP* in **Name**.</br> **SKU**: select **Standard**.</br> **Assignment**: select **Static**.</br> Select **OK**. |
71
75
| NIC network security group | Select **Basic**|
72
76
| Public inbound ports | Select **Allow selected ports**. |
73
77
| Select inbound ports | Select **RDP (3389)**|
@@ -84,16 +88,174 @@ Sign in to the [Azure portal](https://portal.azure.com).
An Azure resource group is a logical container into which Azure resources are deployed and managed.
96
+
97
+
Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) named **myResourceGroup** in the **eastus2** location.
98
+
99
+
```azurepowershell-interactive
100
+
$rg =@{
101
+
Name = 'myResourceGroup'
102
+
Location = 'eastus2'
103
+
}
104
+
New-AzResourceGroup @rg
105
+
106
+
```
107
+
108
+
### Create a public IP address
109
+
110
+
Use [New-AzPublicIpAddress](/powershell/module/az.network/new-azpublicipaddress) to create a standard public IPv4 address.
111
+
112
+
The following command creates a zone-redundant public IP address named **myPublicIP** in **myResourceGroup**.
113
+
114
+
```azurepowershell-interactive
115
+
## Create IP. ##
116
+
$ip = @{
117
+
Name = 'myPublicIP'
118
+
ResourceGroupName = 'myResourceGroup'
119
+
Location = 'eastus2'
120
+
Sku = 'Standard'
121
+
AllocationMethod = 'Static'
122
+
IpAddressVersion = 'IPv4'
123
+
Zone = 1,2,3
124
+
}
125
+
New-AzPublicIpAddress @ip
126
+
```
127
+
### Create a virtual machine
128
+
129
+
Create a virtual machine with [New-AzVM](/powershell/module/az.Compute/new-azvm).
130
+
131
+
The following command creates a Windows Server virtual machine. You enter the name of the public IP address created previously in the **`-PublicIPAddressName`** parameter. When prompted, provide a username and password to be used as the credentials for the virtual machine:
132
+
133
+
```azurepowershell-interactive
134
+
## Create virtual machine. ##
135
+
$vm = @{
136
+
ResourceGroupName = 'myResourceGroup'
137
+
Location = 'East US 2'
138
+
Name = 'myVM'
139
+
PublicIpAddressName = 'myPublicIP'
140
+
}
141
+
New-AzVM @vm
142
+
```
143
+
144
+
For more information on public IP SKUs, see [Public IP address SKUs](public-ip-addresses.md#sku). A virtual machine can be added to the backend pool of an Azure Load Balancer. The SKU of the public IP address must match the SKU of a load balancer's public IP. For more information, see [Azure Load Balancer](../../load-balancer/skus.md).
145
+
146
+
View the public IP address assigned and confirm that it was created as a static address, with [Get-AzPublicIpAddress](/powershell/module/az.network/get-azpublicipaddress):
> Do not modify the IP address settings within the virtual machine's operating system. The operating system is unaware of Azure public IP addresses. Though you can add private IP address settings to the operating system, we recommend not doing so unless necessary, and not until after reading [Add a private IP address to an operating system](virtual-network-network-interface-addresses.md#private).
An Azure resource group is a logical container into which Azure resources are deployed and managed.
169
+
170
+
Create a resource group with [az group create](/cli/azure/group#az-group-create) named **myResourceGroup** in the **eastus2** location.
171
+
172
+
```azurecli-interactive
173
+
az group create \
174
+
--name myResourceGroup \
175
+
--location eastus2
176
+
```
177
+
178
+
### Create a public IP address
179
+
180
+
Use [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) to create a standard public IPv4 address.
181
+
182
+
The following command creates a zone-redundant public IP address named **myPublicIP** in **myResourceGroup**.
183
+
184
+
```azurecli-interactive
185
+
az network public-ip create \
186
+
--resource-group myResourceGroup \
187
+
--name myPublicIP \
188
+
--version IPv4 \
189
+
--sku Standard \
190
+
--zone 1 2 3
191
+
```
192
+
### Create a virtual machine
193
+
194
+
Create a virtual machine with [az vm create](/cli/azure/vm#az-vm-create).
195
+
196
+
The following command creates a Windows Server virtual machine. You enter the name of the public IP address created previously in the **`-PublicIPAddressName`** parameter. When prompted, provide a username and password to be used as the credentials for the virtual machine:
For more information on public IP SKUs, see [Public IP address SKUs](public-ip-addresses.md#sku). A virtual machine can be added to the backend pool of an Azure Load Balancer. The SKU of the public IP address must match the SKU of a load balancer's public IP. For more information, see [Azure Load Balancer](../../load-balancer/skus.md).
209
+
210
+
View the public IP address assigned and confirm that it was created as a static address, with [az network public-ip show](/cli/azure/network/public-ip#az-network-public-ip-show):
> Do not modify the IP address settings within the virtual machine's operating system. The operating system is unaware of Azure public IP addresses. Though you can add private IP address settings to the operating system, we recommend not doing so unless necessary, and not until after reading [Add a private IP address to an operating system](virtual-network-network-interface-addresses.md#private).
When no longer needed, delete the resource group and all of the resources it contains:
230
+
When resources are no longer needed, delete all resources created in this article to avoid incurring charges.
231
+
232
+
# [Azure portal](#tab/azureportal)
233
+
234
+
Use the Azure portal to delete the resource group and all of the resources it contains:
90
235
91
236
1. Enter *myResourceGroup* in the search box at the top of the portal. When you see **myResourceGroup** in the search results, select it.
92
237
93
238
2. Select **Delete resource group**.
94
239
95
240
3. Enter *myResourceGroup* for **TYPE THE RESOURCE GROUP NAME:** and select **Delete**.
96
241
242
+
# [Azure PowerShell](#tab/azurepowershell)
243
+
244
+
Use [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) to remove the resource group and all of the resources it contains:
0 commit comments