Is there any way to create a virtual machine without Public IP address in Windows Azure? Even if you are creating a VM in virtual network we cannot control the Public IP assigned by Azure. Is there any way to disable or delete the public IP assigned by Azure?
4 Answers
No. A VM will always have Public IP Address. But you can not assign any Endpoints (leave the VM without any Endpoints defined) - this will effectively block all and any Internet traffic for your VM before it event reaches the Internal Data Centre network.
There will always be a Public IP address assigned to any Cloud Service with something deployed. It is up to you to decide whether to allow Internet traffic to your VM or not. And this decision is made via defining Endpoints.
EDIT
Using Azure Resource Manager you can create a VM without Public IP. You can control this setting on the Network Adapter. Within the IP Configurations for your Network Adapter in Azure Resource Manager you mus specify NONE for the Public IP Address setting.
I stumbled across this question via a post on Twitter and saw there wasn't a recent, complete, answer.
Nowadays it's possible to create a virtual machine in Azure without a Public IP address. Check out the sample below. It'll create a VM, a NIC, and a VNet where the VM will be created in.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"my-super-secure-password": {
"type": "securestring"
}
},
"variables": {
},
"resources": [
{
"apiVersion": "2018-10-01",
"dependsOn": [
"my-project-prefix-nic"
],
"location": "westeurope",
"name": "my-project-prefix",
"properties": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": false
}
},
"hardwareProfile": {
"vmSize": "Standard_D8ds_v4"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces','my-project-prefix-nic')]"
}
]
},
"osProfile": {
"adminPassword": "[parameters('my-super-secure-password')]",
"adminUsername": "jan",
"computerName": "my-project-prefix"
},
"storageProfile": {
"dataDisks": [
{
"createOption": "Empty",
"diskSizeGB": 512,
"lun": 0,
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"name": "my-project-prefix-datadisk-0"
}
],
"imageReference": {
"publisher": "MicrosoftWindowsDesktop",
"offer": "Windows-10",
"sku": "20h1-pro-g2",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"diskSizeGB": 256,
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"name": "my-project-prefix-osdisk"
}
}
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2018-11-01",
"dependsOn": [
"my-project-prefix-vnet"
],
"location": "westeurope",
"name": "my-project-prefix-nic",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'my-project-prefix-vnet', 'my-project-prefix-subnet')]"
}
}
}
]
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "2018-11-01",
"location": "westeurope",
"name": "my-project-prefix-vnet",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "my-project-prefix-subnet",
"properties": {
"addressPrefix": "10.0.0.0/24",
"delegations": []
}
}
]
},
"type": "Microsoft.Network/virtualNetworks"
}
]
}
As you can see, I'm omitting the publicIPAddress
property on creation of the VM. Seeing it's not a mandatory property, it's still a valid resource.