Azure - create multiple Virtual Machines with static addresses - conflicts - azure

I'm working on a project in which we create labs (for students) in which users can create virtual machines and specify that they ought to have static ip addresses. The problem is that when a virtual machine is created on Azure, it alwayas has a dynamic ip address and only then can be assigned a static one.
Is there a way to make it possible to allocate multiple simultaneously created virtual machines with static ips that were chosen by users? We do store these ip addresses in the database so before the conflict happens in Azure, we can detect it on the database level but it's not enough.
Why?
Because if we create 10 virtual machines at the same time, all of them with specific static ips, some may be created with conflicting dynamic addresses:
vm1: dynamic ip - 10.0.0.2, requested static ip 10.0.0.9
vm2: dynamic ip - 10.0.0.3, requested static ip 10.0.0.15
vm3: dynamic ip - 10.0.0.4, requested static ip 10.0.0.16
vm4: dynamic ip - 10.0.0.5, requested static ip 10.0.0.17
vm5: dynamic ip - 10.0.0.6, requested static ip ---------
vm6: dynamic ip - 10.0.0.7, requested static ip 10.0.0.19
vm7: dynamic ip - 10.0.0.8, requested static ip 10.0.0.20
vm8: dynamic ip - 10.0.0.9, requested static ip 10.0.0.21
vm9: dynamic ip - 10.0.0.10, requested static ip 10.0.0.8
vm10: dynamic ip - 10.0.0.11, requested static ip 10.0.0.6
After creation of these vms, when trying to assign 10.0.0.9 to vm1, there will be an error because vm8 has this ip address (although it doesn't want it either, it wants to change to 10.0.0.8 which is taken as well).
I guess a centralized point for creation would be perfect but unless there is something like that on Azure, I don't think it can be done on our end.
Any thoughts?

In the Azure portal, if you use the UI to create VMs directly, a lot of steps will be done by Azure in the backend so that you cannot control the creation. I suggest that you can use the Azure Template or Azure CLI and Azure PowerShell script to achieve it. You can select one of the above three methods. Then you can create the NIC with the Static allocate method.

Related

Azure virtual machine scale set agents public IP

I was following this article - Azure virtual machine scale set agents. Everything is good and I am able to run my custom images to perform builds and deployments.
One thing that is missing there - what if agent needs to access some IP restricted resource? Previously (with a simple VM running as agent) it was easy to whitelist public IP of a given agent. With those scale sets (and --load-balancer "") I am not sure how to get them to use a static IP (preferably only 1 outgoing public IP for all VMs in a set)
Any suggestions?
When you use a Load Balancer in front of the VMSS with only one static public IP address, then all the VMSS instances only can access outside through that one static public IP address. It's easy to achieve it, you just need to configure the public IP address as static. Then you put that public IP address in the whitelist for the restricted resource.
In this way, all the instances access the restricted resource via the static public IP address and it's in the whitelist.

Azure Load balancer static IPs

Are Azure public IPs truly static or can they change?
I have 2 load balancers each have 2 VMs behind them.
I offer a multi-tenant SAAS solution to my end users and ask that they map a CNAME record in their DNS to our domain name. www.ourDomain.com
There are some scenarios where i would allow the end user to map an A record to our IPs. How risky is this with Azure IPs?
In fact, whatever basic or standard load balancer you are using, both are supporting to assign the public-facing load balancing solution with the static allocation method.
For basic SKU LB, you can change the basic public IP from the dynamic allocation method to static, for standard SKU LB, Azure always uses static allocation method for your standard public IP.
So there is no risk unless you are assigning the public IP to other resources or release these public IPs. For more details, you can look at this.
Static addresses are only released if a network interface is deleted.
If you change the allocation method to dynamic, Azure dynamically
assigns the previously assigned static IP address as the dynamic
address, even if the address isn't the next available address in the
subnet's address range. The address also changes if the network
interface is assigned to a different subnet within the same virtual
network, but to assign the network interface to a different subnet,
you must first change the allocation method from static to dynamic.
Once you've assigned the network interface to a different subnet, you
can change the allocation method back to static, and assign an IP
address from the new subnet's address range.
If you change the setting to static ip in the load balancer , it should remain static until you change it again.

Dynamic Azure public IP Address

In which scenario can we use a dynamic public IP Address ? I cannot think of a scenario where i would want to expose a public IP for internet facing azure services but that could be dynamic.
The two scenarios we use dynamic IPs are
A VM has a mechanism to auto update a DNS A record with its new address.
The Ip address has a CNAME mapped to the DNS name - so mapping www.example.com to example.westus2.cloudapp.azure.com This way whenever the address changes it still points to the same thing.
Remember though that a dynamic IP address doesn't change unless the VM is deallocated. Or the underlying host fails and VM is started on another host.
Hope this helps- https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-ip-addresses-overview-arm
That outlines the use cases for both static and dynamic IPs.
The main use case for dynamic PIP's for me is for gateways. For web or app services I would use static.

Changing Azure VM ip address without downtime

I have an Azure VM with SQL Server on. There are a number of applications using this database via it's public ip address. The ip address is currently set to Dynamic and the VM requires maintenance which could change it. Is there a way of assigning a static ip address to the VM while keeping the current one active while I update the applications to use the new static one?
Is there a way of assigning a static ip address to the VM while
keeping the current one active while I update the applications to use
the new static one?
If I understand it correctly, you just want to change the public IP address to static.
We can change the public IP address to static via Azure portal, that IP address will not change.

The IP address of my Azure Windows VM changed without waning

A few days ago, the IP address of our VB Windows Server changed from 40.x.x.x to 13.x.x.x on the Azure platform. We have many loggers in the field that connect to this IP address and now, none of them can connect.
Can the IP change without any warning from Azure?
Also, there is no support to be found. No number, no online support... I mean, This is not a problem I should be paying support for... besides.. support is more expensive than the VM.
Your IP address will change if, for instance, you restart your virtual machine. However, you can set this to be static by doing so:
go to Public IP addresses
Click Configuration
Set assignment to Static
Click Save
This will retain the IP address that you have right now but at an additional cost.
Can the IP change without any warning from Azure?
For now, there is no warning when public IP address change. I think you should know IP address types and allocation methods in Azure.
There are two methods in which an IP address is allocated to a public IP resource - dynamic or static. The default allocation method is dynamic, where an IP address is not allocated at the time of its creation. Instead, the public IP address is allocated when you start (or create) the associated resource (like a VM or load balancer). The IP address is released when you stop (or delete) the resource. This causes the IP address to change when you stop and start a resource.
If you want to public IP address not change, you could change dynamic to static.

Resources