0
votes

I've 8 VMs (linux based) running a single VNet on Azure. If I've two VMs running a service on the same port which shows me machine status or shows some common details which is specific to the VM. Say for example

VM-1 runs a service on 8080 port and same same service has been deployed on VM-2 which runs on the same port 8080. To access to a service running on port 8080 I am opening a port on VM-1 through end points. I am able to access 8080 from web browser through VM-1 using servicename.webapp.net:8080. But If I want to check the status of VM-2, I am not able to open the port 8080 on the VM-2. Probably because the port is opened at the service level and not the VM level. Is there a way I can open the port at the VM level and use VM-x:port?

Another approach I thought which could be useful is : Assign the staticIP/ReservedIP to each of the VM and open the port on individual machines should be possible, instead of open the port at the VNet/service level. Is it possible to assign static/reserved IP to all 8 of the machines once they have been started and operational? And we also need to make sure that, after restart all the eight machines retain the same IPs.

I tried following blog https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-reserved-public-ip/ and tried following command :

$image = Get-AzureVMImage|?{$_.ImageName -like "*AMI-20150919-849187*"} 
New-AzureVMConfig -Name StaticIPVMCOnfig -InstanceSize Small -ImageName $image.ImageName 
-CurrentStorageAccountName "myStorageACName" 
| Add-AzureProvisioningConfig -Linux -LinuxUser root -Password MyP@ssword! 
| New-AzureVM -ServiceName myCloudServiceName -ReservedIPName MyReservedIP 
-Location "West Europe"

I still see the new VM is getting launched with same same VIP as the other VMs in the VNet. I am not sure if I am missing something.

Attaching the screenshots one is created without static/reservedIP CMDlets. Another is created from PowerShell. Both share the same VIP.

This VM is created before without powershell or reservedIPs

This VM is created with Powershell. Could someone please help with this?

PS: Intentionally I am keeping the public VIPs to show that they are same. (I've closed and not using this service anymore).

Thanks, JE

1

1 Answers

1
votes

Yes you can assign static IP to to the VMs using powershell command-

get-azurevm -servicename "testservice" -name "testvm" | Set-AzureStaticVNetIP -IPAddress "10.87.96.41" | Update-AzureVM

Next thing is you want to make sure you don't lose the IP when instance goes to stopped state. For this what you can do is define explicit parameter StayProvisioned with the stop azure vm command in powershell-

stop-azurevm -ServiceName "testservice" -Name "testvm" -StayProvisioned

StayProvisioned doesn't allow IP to be freed even if VM is stopped.

If you are looking for public IP of VM-

"Every Virtual Machine is automatically assigned a free public Virtual IP (VIP) address"

In order to find out the public ip goto- Azure portal and then your VM dashboard. Here at the right side you see a quick glance tab under which you will be able to see the public IP. Snapshot for your reference-

enter image description here

You can use this public ip to directly connect to vm using RDP. Using powershell you can use below command for the same.

Get-AzureVM -ServiceName "testservice" -Name "testvm" | select PublicIPAddress

NOTE - Public IP will be null if instance is in stopped state. To know more on public IP you can read this-

https://azure.microsoft.com/en-in/documentation/articles/virtual-networks-instance-level-public-ip/

[Edited]