Assign VNet IP address to Azure Cloud Service - azure

I have an Azure Cloud Service, and a Azure Virtual Network with Subnet.
I can deploy the Cloud Service onto the Virtual Network by setting the appropriate configuration setting in the .cscfg.
What I'm struggling with though is bringing the role onto a specific IP address. My guess is that it's currently using DHCP to get an IP address.
I've tried using the following Powershell:
Get-AzureVM -ServiceName myrole | Set-AzureStaticVNetIP -IPAddress 127.16.0.4 | Update-AzureVM
But the IP address never changes:
<IpAddress>172.16.0.5</IpAddress>
Is there a restriction on doing this on cloud services?
Any help would be really appreciated.
Thanks,
Graeme

Network configuration schema for Cloud Service is documented here.
https://msdn.microsoft.com/library/azure/jj156091.aspx
As you'll see, you have the ability to specify a ReservedIP but not a static private IP.
My understanding is that Set-AzureStaticVNetIP works for Azure IaaS VM, not for Cloud Service VM.
Virtual machines whether there are IaaS or Paas provisioned in a VNET are always allocated the first available IP address in the subnet after the first 4 addresses which are reserved from .0 to .3.
So considering your request, I will define subnets that enable to target the right subnet IPs for my role instances, and if I need to precisely know which IP is used by which instance, read it in the "role start" method and use it to configure whatever solution you need for this IP to be be "static".
Hope this helps
Best regards
Stéphane

Related

App Services in peered Azure vnet not working

In my Azure subscription I have 2 peered VNETs. VNET1 has address space 10.16.0.0/16 and VNET2 has 10.250.21.0/24. I have chosen the space addresses so that they were completely different. Peering works given that a VM in VNET1 can ping a VM in VNET2.
However, from VNET 1 I can't access an App Service deployed in VNET2. I tried to access the App Service using the IP address and the private DNS name.
Network Security Groups in both VNETs seem to be fine. I'm able to change them so that basic network diagnostics work (for instance, ping).
Any suggestions please?
EDIT 1 + SOLUTION
I can say that it's solved. After peering the virtual networks, I had to "link the private DNS zones". I had a few issues with the address spaces, but nothing that a terraform destroy/apply couldn't solve.
I tried to reproduce the same in my environment and got the results like below:
I have created a vnet peering with two different space address like below:
Created a app service with premium p1v2 and added outbound traffic vnet integration and added a private endpoint like below:
Then, I created a vm and connect through bastion:
When I try to verify in command prompt using nslookup got result successfully like below:

DHCP server on Azure portal

I’m working on Azure portal to create virtual machines with bastion and I was wondering, can I use DHCP server for internal IP addresses? I’m not sure it is possible because when I create a machine it already has an internal IP.
DHCP by default does not exist in Microsoft Azure.
Or you may call it as vNet.
Just like you create a "Scope" of IP addresses in DHCP in an on-premesis environment, similarly, in Azure, you create "Subnet" in "vNet" and then when you create a VM and attach a vNet to it then the IP address is assigned from that subnet.
In simpler terms (not exact terms), you can say that:
vNet -> DHCP
Subnet -> Scope
I just wrote above relation in simpler terms so that you are able to understand it easily.
That's what Azure Virtual Networks is for. Take a look at their documentation here: https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview

How do I use the default 'Internal Azure DNS' to resolve DNS names of worker roles within the same Azure Virtual Network?

I have a cloud service that has a worker role 'Kernel' with 2 instances (instance 0, and instance 1). I have another VM deployed in a different subnet, in the same Azure Virtual Network. I heard that I can use Azure DNS to resolve a hostname to get the private (dynamic) IP address of each worker role. But how do I actually do that? I assume on the client side this is just a standard DNS lookup, so the question is really: what do I put in the CSCFG file, and what FQDN DNS name is actually what I should resolve?
To set the name on the worker role VMs, add vmName to the cscfg as described here: https://msdn.microsoft.com/en-us/library/azure/jj156212.aspx
The two workers will have a common DNS suffix so you can just refer to them by name. To find the FQDN you'll either need to login to one of the VMs and do ipconfig /all or use the powershell Get-AzureVM cmdlet with the -Debug switch and look for InternalDnsSuffix.
Regards
Gareth [MSFT]

Azure Reserved IP Address Inconsistency

I had a need to add additional public IP addresses to an Azure VM and found a working solution here:
Azure VM: More than one Public IP
Essentially this creates a reserved IP in Azure and then adds the reserved IP to a cloud service. Once it's bound to a cloud service it can be mapped to a VM endpoint.
This all works great but there is one bit I don't understand - The IP address of the reserved IP and the resultant VM endpoint don't match. I have to set up DNS to point to the IP address of the endpoint to make this work. Is there something I am not doing right, or is this just the way reserved VMs work?
It looks like this unanswered question is the same issue:
azure reserved IP for VM is diffrent than the given
Thanks!
The "Azure Cloud Service" is a container that provides internet connectivity to "Azure VMs". Thus, you assign the Internet facing Public IP to the Cloud Service. This article is relatively good at explaining the relationship: Azure Cloud Services
From above link:
Here’s a definition of an Azure IaaS cloud service that will make it easy for you to understand what it is in the context of Azure Infrastructure Services:
A cloud service is a network container where you can place virtual machines.
All virtual machines in that container can communicate with each other directly through Azure (and therefore don’t have to go out to the Internet to communicate with each other).
This container is also assigned a DNS name that is reachable from the Internet.
A rudimentary DNS server is created and can provide name resolution for all virtual machines within the same cloud service container (note that name resolution provided by the DNS server is only available to the virtual machines that are located within the cloud service).
One or more Virtual IP Addresses (VIPs) are assigned to the container and these IP addresses can be used to allow inbound connections from the Internet to the virtual machines.
Certain services (like FTP) may require your vm have a public IP: Azure VM Public IP
(IaaS v1) An Azure cloud service comes with a permanent DNS name - something.cloudapp.net - and has a single VIP allocated whenever there are VMs deployed in it OR whenever a reserved IP address is associated with it. Traffic is either load balanced or NATted (port forwarded) to the VM from the Azure Load Balancer sitting on the VIP. You can also associate a public instance-level IP address (PIP) with a VM, which gives it an additional IP address. The VIP always has a DNS name (something.cloudapp.net) while the PIP has one only if you specifically add it, I did a post which goes into these differences.
(IaaS v2) VMs are not deployed into cloud services and only have a public IP address if one is specifically added - either by configuring a PIP on the NIC of the VM (and optionally giving it a cloudapp.azure.com DNS name) or by configuring a load balancer and either load balancing or NATting traffic to it. This load balancer is configured with a public IP address and can optionally have a cloudapp.azure.com DNS name associated with it. (Ignoring internal load balancers in this discussion.)

Azure VM: More than one Public IP

Can anyone confirm if Azure VM allows more than one Public IP? We want to host multiple website on single VM and hence want to have different IP for each website. I know we can host more VM, but that will greatly increase our expense too. So, I just want more than 1 Public IP on VM.
You can add multiple IP addresses for a cloud service. Since the VM's are "inside" the cloud service, this gives you in a way multiple public IP addresses for a virtual machine. The procedure is documented at [1]. Additional addresses currently cost about $3/month.
Here's the steps to add a new reserved IP address to a cloud service.
First create a new reserved IP address:
New-AzureReservedIP –ReservedIPName "MyIPAddress" –Location "West Europe"
Associate the IP address with cloud service:
Add-AzureVirtualIP -VirtualIPName MyIPAddress -ServiceName MyCloudService
Create endpoint that maps the IP address to a virtual machines. If you have multiple vm's and want load balancer, repeat this for each vm. In order to run multiple web sites, you would put each website to different port (the localport). The endpoint listens for connections on the public port and forwards them to the virtual machine's localport.
Get-AzureVM -ServiceName MyCloudService -Name myserver `
| Add-AzureEndpoint -Name QuvastoMail -Protocol tcp `
-LocalPort 8002 -PublicPort 80 -VirtualIPName MyIPAddress `
| Update-AzureVM
[1] http://azure.microsoft.com/en-us/documentation/articles/load-balancer-multivip/
It appears you can now have multiple public IPs for a load balanced cloud service:
http://azure.microsoft.com/en-gb/updates/multiple-vips-per-cloud-service/
Now you can assign more than one load-balanced public IP address to a
set of virtual machines, enabling high-availability and high-scale
scenarios. You can host multiple secure websites in a cloud service or
allow multiple SQL Server AlwaysOn Availability Group listeners to
access the same set of virtual machines.
For more information, please vistit the Load Balancer page. There is
no additional charge for this feature.
You would need a different Cloud Service (either Web Role or Virtual Machine) to have different IP addresses. Yes, this will increase overall cost.
The VIP (public IP) for Windows Azure Web Roles and VMs is assigned at the Cloud Service level. Think of a Cloud Service as a logical container - it can contain web/worker roles or VMs (not both currently).
Very possible, very easy actually.
Have your apps listening at your Azure Resource Managed VM, let's say ports 3001, 3002, 3003..
Then create an Load Balancer (just search it).
Create a Public IP Address.
Add it at your Load Balancer's Front-end Pool
Add your VM to your Load Balancer's Back-end Pool
at Inbound NAT rules of your Load Balancer, click "Add"
Select your frontend IP, your VM's network IP configuration, protocol, port and mapped port (click "Custom") to set a custom port.
Sample:
- You want your newly created public ip "52.165.147.25" to route to your vm's port 3001.
- On config that will be port 80 tcp, then port 3001 on mapped port.
- No need to enable "Floating IP (direct server return)" in case you see it.
PS:
On linux VM's you might have to "Optimize Your Network Kernel Parameters"..
Check here (scroll at bottom): http://docs.fluentd.org/v0.12/articles/before-install
sudo nano /etc/sysctl.conf
Add these entries:
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535
Note the spaces, crucial.
Save it.
sudo sysctl -p
Done.
EDIT:
On the above steps you might have to also take care of CORS (Just google it)
Also, Another alternative I forgot to mention is to add NIC's / Network Interfaces to ya VM's. That won't be a viable option though because of azure max-nic-per-vm limits.
In addition to the earlier answer about Cloud Services, it is now possible to have multiple IP addresses on an Azure VM. https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-multiple-ip-addresses-portal
You can only have one public IP address per deployment. So if you had 3 VMs in a single deployment, they'd share IP address. You can then choose to load-balance traffic across the instances or direct traffic to a particular VM (or role in cloud services) for a specific port number.
You can use host headers and support multiple websites in a single VM.
We are also having similar problems. We wanted to have multiple SSL certificates applied to multiple sites hosted withing Virtual Machine.
but it seems its not possible at all. Waiting for MS to release this feature.
Comparatively Godaddy and other hosting providers give free 2-3 IP addressed as well if you need more you can request additional Ip Address easily.
as well to get hold of support is too much difficult.
MZ azure really sucks. :(

Resources