0

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

java_enthu
  • 2,279
  • 7
  • 44
  • 74

1 Answers1

1

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]

Aatif Akhter
  • 2,126
  • 1
  • 25
  • 46
  • Thanks. I believe this fixes the IP inside the service hence all the IPs inside a services have static IPs. But still you can't access this VM from a browser using IP. I am looking for something which assigns the fixed public IP to a VM. – java_enthu Sep 20 '15 at 19:25
  • This assigns fixed private ip to vm. You can rdp using this ip. – Aatif Akhter Sep 20 '15 at 19:29
  • However if you want to use reserved IP to your existing vm then this link will surely help you- http://stackoverflow.com/questions/28454255/azure-vm-adding-a-reserved-ip-address-to-an-existing-vm – Aatif Akhter Sep 20 '15 at 19:38
  • Well I tried this Aatif, it helps when I have one VM instead of 8 vms in the same VNet. – java_enthu Sep 20 '15 at 21:37
  • The link you shared I visited it previously thanks :) – java_enthu Sep 20 '15 at 21:38
  • Hai Aatif, this will definitely work if the cloud service has only one VM. In the case of multiple VMs in a single cloud service it's not working. – java_enthu Sep 20 '15 at 22:03
  • Azure Doc. says: "Every Virtual Machine is automatically assigned a free public Virtual IP (VIP) address" – Aatif Akhter Sep 20 '15 at 22:10
  • I did go through the document : https://azure.microsoft.com/en-in/documentation/articles/virtual-networks-instance-level-public-ip/ Also tried following the command given there : $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" – java_enthu Sep 20 '15 at 22:27
  • This brings up a new VM from the image but, the VIP what I see is the same as other VMs. :) So, still I am not able to use it VM:port. – java_enthu Sep 20 '15 at 22:28
  • Well I got a useful link for you. You can add a public IP on VM level- http://blogs.technet.com/b/canitpro/archive/2014/10/28/step-by-step-assign-a-public-ip-to-a-vm-in-azure.aspx However new IP will be picked once you shut down and restart the VM, as Azure public IP is dynamic. – Aatif Akhter Sep 21 '15 at 13:03