azurepowershellazure-virtual-machineazure-public-ip

Create VM in Azure with powershell with no public IP


I'm creating VM on Azure from an Image using powershell.

This is the script I'm using .

$UserName = "username"
$Password = ConvertTo-SecureString "password@123" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($UserName, $Password)    
New-AzureRmVm `
    -ResourceGroupName "RSG" `
    -Name "VMName" `
    -ImageName "ImageName" `
    -Location "West US" `
    -VirtualNetworkName "VNName" `
    -SubnetName "default" `
    -Credential $psCred
    -PublicIpAddressName "None" `
    -OpenPorts 3389

But, when I got into the Azure portal and see, some Public Ip is getting assigned by default. I have also tried without giving PublicIpAddressName property assuming , it wont assign any IP, but still it is assigning.

I want the Public IP to be none.Can anyone help me achieve this.Thanks!


Solution

  • Currently this an issue which is still in Open state on official azure-powershell github. You can refer it here . Incase if you still want to bypass this you can try using New-AzureReservedIP or after the deployment command try to remove the public ip by yourself Remove-AzureRmPublicIpAddress.

    Note : I have'nt tested it yet. Just an idea.

    Refer : Docs