Create a Virtual Machine with 2 NICs in Azure Classic
Unfortunately, in Azure you cannot create a Virtual Machine in the GUI with 2 Network Cards. You cannot even add a 2nd NIC to a VM once it has been created. The only way to create a VM with 2, is to specify the additional NIC’s at the time of creation and ONLY via powershell. I have compiled a Powershell script that will do this. I have also listed the commands next to each comment to get the value to put there. Copy the code below into a PS1 and launch it from a PowerShell window.
############## Change Values Below Here #############
# Set Subscription that will be used. Get-AzureSubscription
$subscr="Free Trial"
# Cloud Service Name. Get-AzureService
$svcname="Cloud Service"
#Set Storage Account VM will be created in. Get-AzureStorageAccount
$staccount="Storage01"
# Name of the VM Provisioned
$vmname="VM01"
# Instance Size of the VM required
$vmsize="Standard_DS2_v2"
# Virtual Network Name. Get-AzureVNetConfig
$vnetname="Virtual Network"
# OS you want to Deploy
# 2012 = "Windows Server 2012 R2 Datacenter"
# 2008 = "Windows Server 2008 R2 SP1"
$OSversion = "Windows Server 2008 R2 SP1"
# vNic1 IP Address
$vNic1IP = "10.0.2.11"
$vNic1Subnet = "Live"
# vNic2 IP Address
$vNic2Name = "Replication"
$vNic2IP = "10.0.1.11"
$vNic2Subnet = "Replication"
############# DO NOT CHANGE VALUES BELOW HERE ############
# Select Subscription and Storage
Set-AzureSubscription -SubscriptionName $subscr -CurrentStorageAccountName $staccount
# Get image for VM
$image = Get-AzureVMImage `
| where{$_.ImageFamily -eq $OSversion} `
| sort PublishedDate -Descending `
| select -ExpandProperty ImageName -First 1
# Creates a new VM config with the VM name, its Size and the Image Used
$vm1 = New-AzureVMConfig -Name $vmname -InstanceSize $vmsize `
-Image $image
# Asks you for the admin username and password for the machine
$cred=Get-Credential -Message "Type the name and password of the local administrator account."
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $cred.Username -Password $cred.GetNetworkCredential().Password
###### 2nd Network Card - Remove comments on next 2 lines if you need a 2nd NIC #
#Add-AzureNetworkInterfaceConfig -Name $vNic2Name `
# -SubnetName $vNic2Subnet -StaticVNetIPAddress $vNic2IP -VM $vm1
# Create vNic1 - Will be the Default Gateway so assign to Correct Subnet
Set-AzureSubnet -SubnetNames $vNic1Subnet -VM $vm1
Set-AzureStaticVNetIP -IPAddress $vNic1IP -VM $vm1
New-AzureVM -ServiceName $svcname –VNetName $vnetname –VMs $vm1
Author
Related Posts
Diving into Primary Refresh Tokens and Authentication Strengths in Microsoft Entra ID
Microsoft Entra ID is the backbone of modern identity management, powering secure access to cloud and hybrid resources. At its core, the...
- authentication
- Biometrics
- Certificate-based Authentication
- Conditional Access
- Cybersecurity
- Device Binding
- Federated Authentication
- FIDO2
- Hybrid Access
- Identity Management
- Kerberos
- MFA
- Microsoft Authenticator
- Microsoft Entra ID
- Multi-factor Authentication
- NTLM
- OAuth 2.0
- OpenID Connect
- Passwordless
- Phishing-resistant
- Primary Refresh Token
- PRT
- SAML
- Security Keys
- Single Sign-On
- Smartcard
- SSO
- Temporary Access Pass
- Windows Hello
- WS-Federation
Mastering PRT Delayed Renewal in Microsoft Entra ID: Controls, Configurations, and Real-World Scenarios
In the evolving landscape of identity management, the Primary Refresh Token (PRT) stands as a cornerstone of seamless single sign-on (SSO) in...
Read out all
Understanding Tokens in Microsoft Entra ID: Types, Lifetimes, and Beyond
In the world of modern identity and access management, tokens are the digital keys that unlock secure access to resources. Microsoft Entra...
Read out all
Adding an Application Registration\ Service Principal to another Application Registration\ Service Principal
Typically when working with App Roles in Azure Active Directory for a single application registration or service principal and then self consuming...
Read out all
Get Primary, Secondary, Tertiary DNS values and more from Multiple Servers
Came across a unique request to get primary, secondary, and tertiary DNS values for multiple computers/servers across the domain. I started writing...
Active Directory Ports required between client and domain controllers
Active Directory uses several ports for communication between domain controllers and clients. These ports are required both by client computers and Domain...
Read out all