How to create a VM with multiple NIC's in Azure ARM - azure

Has anyone been able to create a VM with multiple private IP's in ARM? I've tried setting different VM sizes but still cannot find out how to attach multiple NIC's to 1 VM. I'm trying to do this in the new ARM mode but cannot find a way to do so.
Thanks!

You can only add multiple network interface resources to a VM using PowerShell or JSON, and it can only be done during VM creation.

The nics have to have been created before hand and you have to choose a vm which supports multiple NICs. Also, Create a virtual network with one subnet must have been created before hand as well.
Using Azure Cli 2.0
azure login
azure config mode arm
azure vm create -g myresourcegroup -n myVMname -l AzureLocation -y {windows|linux} -N myNic1, myNic2 -Q Win2012R2Datacenter -u myUserName -p myPassword -z ‘AzureVM Size’ -v
Wait 5 minutes
and you are done

Related

How to rename the multiply VM hostname in azure\how can I deploy multiple instances of VM from custom image with different hostname

I want to create 70 VM's of the same OS in Azure. For this, I have created a VM converted to a custom image of it so that I can deploy 70 instances of this machine.
The issue here for me is if I deploy 70 instances of VM via custom images I am getting the hostname of all the VM's as same. All 70 VM's hostname is WIN2K12.
Is there any way where I can change this hostname while deploying?
I'm dealing with the same question right now and my solution is run a remote PowerShell command through Azure CLI (Linux shell in the example below) in the VMs that need to have their hostnames changed. Basically is something like this:
$RG = "Your Resource Group Name"
$OLD_NAME = "The replicated hostname name"
$NEW_NAME = "The new hostname"
$VM_NAME = "The VM's name that you just created/copied"
az vm run-command invoke \
--resource-group $RG \
--name $VM_NAME \
--command-id RunPowerShellScript \
--scripts "Rename-Computer -ComputerName $OLD_NAME -NewName $NEW_NAME"
I guess you can adapt it to get parameters from command line etc.
Don't forget to restart the VMs after this.
Point of clarification.
If you create VM from a Image they will not/should not have the same Hostname. Part of process of making an Azure Custom Image is to sysprep machine which guarantees the hostname will be different when you deploy new VM using that image.
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource
In Azure the only time VM will get the same host name is if you create VM from a specialized disk, meaning create VM from a copy of the same disk (not really image).
The thing you have to confirm is if your applications on the VM allows sysprep.
Since you chose "NO" on SysPrep the image is not generalized. You're basically creating 70 copies of the same harddrive and starting them. Sysprep ensures that the server upon boot accepts either manual or scripted input to change hostname among other things.

how to disable Accelerated Networking on Azure VM

i have enabled Accelerated Networking on Azure Vm..now i want to disable accelerating networking but unable to find a way. since i want to change the size of vm and accelerating network is preventing to change the size.
please suggest
This is a setting on the network interface. For a single machine you could try running this command from the cloud shell on the azure portal:
az network nic update --accelerated-networking false --name <network interface name> --resource-group <resource group name>
Recommend typing this command out not copy pasting from this page to avoid hyphen hell. Case sensitive so all lower case.
https://learn.microsoft.com/en-us/cli/azure/network/nic?view=azure-cli-latest#az-network-nic-update
For VMSS (Virtual Machine Scale Sets), the process is a bit less straight forward, but still possible.
Say your resource group is RG001 and the VMSS name is VMSS001, then you can issue
az vmss update -g RG001 -n VMSS001 --set virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].enableAcceleratedNetworking=false
I added a new NIC from the VM networking tab and it seems that accelerated networking is disabled by default. Then I detach the previous NIC (with accelerated networking) and was able to resize my VM.
You could try to use azure powershell to do it.
Remove-AzureRmAcceleratedNIC -ResourceGroupName <ResourceGroupName> -VMName <VMName> -OsType <OsType>
You need to download the script file in this link, then refer to the usage below.
For more details, refer to this link.

Is it possible to update already deployed VM to use Azure KeyVault?

I have about 200+ VMs (Windows & Linux) already deployed in Azure. I want to know if it is possible to use either Powershell or Azure CLI to update the VMs to use KeyVault as a password/key manager.
It is possible. You could use az vm update -n shui -g shuikeyvault --set to configure it. You could check this answer.
In fact, you could create a VM to use Key Vault, then use az vm show to get this parameters and use az vm update --set.

Azure vmss without a load balancer

My requirement is to scale vm instance (linux based custom image) based on CPU usage. Tried to follow steps mentioned in VMSS (virtual machine scale sets : https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-linux-autoscale), but it creates a LB in front which we don't want. Is it possible to avoid LB in vmss ?
If VMSS without LB is not the option, is there any other way in azure to do this ?
I am able to achieve this in AWS (using autoscale group) and GCP (instance group), so trying to get similar functionality in Azure.
hp
In powershell to make this work you need to provide both double quotes wrapped in single quotes: --load-balancer '""'
az vmss -n myName -g myGroup --load-balancer '""' --image UbuntuLTS
Pass empty id as a load-balancer
az vmss create -n myname -g mygroup --load-balancer "" --public-ip-per-vm --image UbuntuLTS
Though a load balancer is created when you create a VM scale set in the portal, other modes supporting external connectivity to scale sets include:
Create a separate VM with a public IP address in the same VNET as the scale set which can route connections to the scale set VMs (also known as a jump box). E.g. https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-jumpbox or https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-linux-jumpbox
Assign a public IP address to each VM in the scale set. This feature is currently in limited preview. See here for more details: https://github.com/gbowerman/azure-myriad/tree/master/publicip-dns
Public IP per VM in a scale set is not supported today but is on the roadmap. If you submit a support request (e.g. from the question mark in the top-right of the azure portal), we can keep you informed on the timeline :).

how can i create a azure VM in a specific cloud service?

When I do (in linux command line):
azure vm create Machine 0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-7.0-x64-v14.2.1 USER passuser --location "West Europe"
there is always a line with "+ Creating cloud service"
how can i do without creating a new cloud service and use one that just exist?
Based on the documentation here, please try with -c or -connect option.
From the documentation page:
vm create [options] [password]
This command creates a new Azure virtual machine. By default, each
virtual machine (vm) is created in its own cloud service; however, you
can specify that a virtual machine should be added to an existing
cloud service through use of the -c option as documented here.

Resources