1
votes

I'm trying to change the TCP Port timeout on my Ubuntu VM in Azure, and am following this guide to do so, however I seem to get stuck at Step 8 where I have to type the following command:

Get-AzureRmVM -Name "digitron" -ResourceGroup "DIGITRON-RG" | Get-AzureRmPublicIpAddress

Where it spits back the following error:

Get-AzureRmPublicIpAddress : The Resource 'Microsoft.Network/publicIPAddresses/digitron' under resource group 'DIGITRON-RG' was not found. StatusCode: 404 ReasonPhrase: Not Found OperationID : '5031da35-262c-4e1a-a85b-885a6a0fd36c' At line:1 char:63 + ... "digitron" -ResourceGroup "DIGITRON-RG" | Get-AzureRmPublicIpAddress + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzureRmPublicIpAddress], NetworkCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzurePublicIpAddressCommand

What's strange here is if I run the command Get-AzureRmVm, the powershell will spit back:

ResourceGroupName Name Location VmSize                OsType NIC ProvisioningState
DIGITRON-RG           digitron eastus Standard_DS2_v2 Linux digitron727 Succeeded

Now reading the error makes me think that the VM itself has no public IP address, but I've set it in the Azure Portal as seen in this image (where it says 40.71.98.172 etc):

in this image

Why is the Powershell giving me this error?

2
FYI in the future, probably best to block out your subscription id.David Makogon
That's a good point, heh.secondubly

2 Answers

0
votes

The Resource 'Microsoft.Network/publicIPAddresses/digitron' under resource group 'DIGITRON-RG' was not found.

Because Get-AzureRmPublicIpAddress can't get the right parameter, this error means the resource can't find in DIGITRON-RG. For test, we can use Get-AzureRmResource to test the resource exist or not:

PS > Get-AzureRmResource |  ?{$_.name = "digitron"}

By the way, the command Get-AzureRmPublicIpAddress need parameters: -Name (the name of the public IP address), -ResourceGroupName (the name of the resource group)

PS > Get-AzureRmPublicIpAddress -Name "jason-ip" -ResourceGroupName "jason"


Name                     : jason-ip
ResourceGroupName        : jason
Location                 : eastus
Id                       : /subscriptions/5xxxxabb-222b-49c3-9488-0361e29a7b15/resourceGroups/jason/providers/Microsoft.Network/publicIPAddresses/jason-ip
Etag                     : W/"5a7200b2-7c2b-4c7a-be27-0bbb7c8f4665"
ResourceGuid             : 32xxxf-750a-46a4-abda-c25xxx2b64
ProvisioningState        : Succeeded
Tags                     :
PublicIpAllocationMethod : Dynamic
IpAddress                : 13.92.255.103
PublicIpAddressVersion   : IPv4
IdleTimeoutInMinutes     : 30
IpConfiguration          : {
                             "Id": "/subscriptions/5xxxxb-222b-49c3-9xx8-0361e29a7b15/resourceGroups/jason/providers/Microsoft.Network/networkInterfaces/jason647/ipConfigurations/ipconfig1"
                           }
DnsSettings              : null

We can use this command to get the public IP direct, and increase the timrout to 30 minutes.

0
votes

Below is the script I used to get the Private and Public IP for an Azure ARM VM:

$rg = Get-AzureRmResourceGroup -Name "MyResourceGroup01"
$vm = Get-AzureRmVM -ResourceGroupName $rg.ResourceGroupName -Name "MyVM01"
$nic = Get-AzureRmNetworkInterface -ResourceGroupName $rg.ResourceGroupName -Name $(Split-Path -Leaf $VM.NetworkProfile.NetworkInterfaces[0].Id)
$nic | Get-AzureRmNetworkInterfaceIpConfig | Select-Object Name,PrivateIpAddress,@{'label'='PublicIpAddress';Expression={Set-Variable -name pip -scope Global -value $(Split-Path -leaf $_.PublicIpAddress.Id);$pip}}
(Get-AzureRmPublicIpAddress -ResourceGroupName $rg.ResourceGroupName -Name $pip).IpAddress

#Output:    
Name      PrivateIpAddress PublicIpAddress
----      ---------------- ---------------
ipconfig1 10.0.0.10        MyVM01-pip

40.80.217.1