Windows Azure – Create Virtual Machine
Hi,
In previous posts, we were talking about :
- How adding your account and work with it: http://pwrshell.net/?p=863 – First steps
- How handle the missing New-AzureVNetwork cmdlet in the Azure PowerShell module: http://pwrshell.net/?p=908 – Network
- How create an affinity group and optimize your Azure storage: http://pwrshell.net/?p=879 – Storage
Now it’s time to build our first virtual machine. At first let’s see chat we can deploy in our network.
Get-AzureVMImage | Select Label -Unique
RightImage CentOS 6.2 x64 v5.8.8.1 RightImage CentOS 6.3 x64 v5.8.8 RightImage CentOS 6.3 x64 v5.8.8.5 RightImage CentOS 6.3 x64 v5.8.8.6 RightImage CentOS 6.3 x64 v5.8.8.7 RightImage CentOS 6.3 x64 v5.8.8.8 RightImage CentOS 6.3 x64 v5.8.8.9 RightImage-CentOS-6.4-x64-v13.4 RightImage CentOS 6.4 x64 v13.5.0.1 RightImage CentOS 6.4 x64 v13.5.0.2 RightImage CentOS 6.5 x64 v13.5.2 RightImage-Ubuntu-12.04-x64-v13.4 RightImage Ubuntu 12.04 x64 v13.5.0.1 RightImage Ubuntu 12.04 x64 v13.5.2 RightImage Ubuntu 12.04 x64 v5.8.8 RightImage Ubuntu 12.04 x64 v5.8.8.5 RightImage Ubuntu 12.04 x64 v5.8.8.7 RightImage Ubuntu 12.04 x64 v5.8.8.8 JDK 6 (Preview) on Windows Server 2012 JDK 7 (Preview) on Windows Server 2012 Oracle Database 11g R2 Enterprise Edition (Preview) on Windows Server 2008 R2 Oracle Database 11g and WebLogic Server 11g Enterprise Edition (Preview) on Windows Server 2008 R2 Oracle Database 11g R2 Standard Edition (Preview) on Windows Server 2008 R2 Oracle Database 11g and WebLogic Server 11g Standard Edition (Preview) on Windows Server 2008 R2 Oracle Database 12c Enterprise Edition (Preview) on Windows Server 2012 Oracle Database 12c Standard Edition (Preview) on Windows Server 2012 Oracle Database 12c and WebLogic Server 12c Enterprise Edition (Preview) on Windows Server 2012 Oracle Database 12c and WebLogic Server 12c Standard Edition (Preview) on Windows Server 2012 Oracle WebLogic Server 12c Enterprise Edition (Preview) ... Oracle WebLogic Server 12c Standard Edition (Preview) on Windows Server 2012 Oracle WebLogic Server 11g Enterprise Edition (Preview) on Windows Server 2008 R2 Oracle WebLogic Server 11g Standard Edition (Preview) on Windows Server 2008 R2 BizTalk Server 2013 Enterprise on Windows Server 2012 BizTalk Server 2013 Standard on Windows Server 2012 Windows Server Essentials Experience on Windows Server 2012 R2 OpenLogic Windows Server 2008 R2 SP1, October 2013 Windows Server 2008 R2 SP1, November 2013 Windows Server 2008 R2 SP1, December 2013 Windows Server 2008 R2 SP1, January 2014 Windows Server 2012 Datacenter, October 2013 Windows Server 2012 Datacenter, November 2013 Windows Server 2012 Datacenter, December 2013 Windows Server 2012 Datacenter, January 2014 Windows Server 2012 R2 Datacenter Windows Server 2012 R2 Datacenter, November 2013 Windows Server 2012 R2 Datacenter, December 2013 Windows Server 2012 R2 Datacenter, January 2014 Windows Server 2012 R2 Datacenter, February 2014 Ubuntu Server 12.10 Ubuntu Server 12.04.3 LTS Ubuntu Server 13.10 Ubuntu Server 14.04 LTS Ubuntu Server 12.04.3 LTS DAILY Ubuntu Server 12.04.4 LTS DAILY Ubuntu Server 12.10 DAILY Ubuntu Server 13.10 DAILY Ubuntu Server 14.04 LTS DAILY SUSE Linux Enterprise Server 11 SP3 openSUSE 13.1 RightImage Windows 2008R2 SP1 x64 iis75 v5.8.8 RightImage Windows 2008R2 SP1 x64 iis75 v5.8.8.11 RightImage Windows 2008R2 SP1 x64 sqlsvr2012 v5.8.8 RightImage Windows 2008R2 SP1 x64 sqlsvr2012 v5.8.8.1 RightImage Windows 2008R2 SP1 x64 sqlsvr2012 v5.8.8.12 RightImage Windows 2008R2 SP1 x64 sqlsvr2012 v5.8.8.15 RightImage Windows 2008R2 SP1 x64 v5.8.8 RightImage Windows 2008R2 SP1 x64 v5.8.8.11 RightImage Windows 2008R2 x64 iis7.5 v13.4.12.2 RightImage Windows 2008R2 x64 iis7.5 v13.5 RightImage Windows 2008R2 x64 sqlsvr2012 v13.4.3.1 RightImage Windows 2008R2 x64 sqlsvr2012 v13.5.1 RightImage Windows 2008R2 x64 sqlsvr2012ent v13.4.3.1 RightImage Windows 2008R2 x64 sqlsvr2012ent v13.5 RightImage Windows 2008R2 x64 sqlsvr2k8r2 v13.5 RightImage Windows 2008R2 x64 sqlsvr2k8r2ent v13.5 RightImage Windows 2008R2 x64 v13.4.12.2 RightImage Windows 2008R2 x64 v13.5 RightImage Windows 2012 x64 iis8 v13.4.12.2 RightImage Windows 2012 x64 iis8 v13.5 RightImage Windows 2012 x64 iis8 v5.8.8.12 RightImage Windows 2012 x64 sqlsvr2012 v13.5 RightImage Windows 2012 x64 sqlsvr2012ent v13.5 RightImage Windows 2012 x64 v13.4.12.2 RightImage Windows 2012 x64 v13.5 RightImage Windows 2012 x64 v5.8.8.12 Oracle Database 12.1.0.1 Enterprise Edition on Oracle Linux 6.4.0.0.0 Oracle Database 12.1.0.1 Standard Edition on Oracle Linux 6.4.0.0.0 Oracle Linux 6.4.0.0.0 Oracle WebLogic Server 12.1.2 on Oracle Linux 6.4.0.0.0 SharePoint Server 2013 Trial SQL Server 2008 R2 SP2 Enterprise on Windows Server 2008 R2 SQL Server 2008 R2 SP2 Standard on Windows Server 2008 R2 SQL Server 2012 SP1 Enterprise on Windows Server 2012 SQL Server 2012 SP1 Enterprise on Windows Server 2008 R2 SQL Server 2012 SP1 Standard on Windows Server 2012 SQL Server 2012 SP1 Standard on Windows Server 2008 R2 SQL Server 2012 SP1 Web on Windows Server 2008 R2 SQL Server 2008 R2 SP2 Web on Windows Server 2008 R2 SQL Server 2012 SP1 for Data Warehousing on Windows Server 2012 SQL Server 2014 CTP2 Evaluation for Data Warehousing on Windows Server 2012 SQL Server 2014 CTP2 Evaluation on Windows Server 2012 SQL Server 2014 CTP2 Evaluation on Windows Server 2012 R2
Has you see, we have a “correct” choice for our VM. Let’s start with a Windows 2012 R2 deployment.
Ok, for creating a service we have two cmdlets
- New-AzureQuickVM
- New-AzureVM
I read both descriptions, and i can’t find real difference…. so let’s use AzureQuickVM for our needs first.
man New-AzureQuickVM NOM New-AzureQuickVM RÉSUMÉ SYNTAXE New-AzureQuickVM -ImageName <string> -Linux -LinuxUser <string> -Password <string> -ServiceName <string> [-AffinityGroup <string>] [-AvailabilitySetName <string>] [-DnsSettings <DnsServer[]>] [-HostCaching <string>] [-InstanceSize <string>] [-Location <string>] [-MediaLocation <string>] [-Name <string>] [-SSHKeyPairs <SSHKeyPairList>] [-SSHPublicKeys <SSHPublicKeyList>] [-SubnetNames <string[]>] [-VNetName <string>] [<CommonParameters>] New-AzureQuickVM -AdminUsername <string> -ImageName <string> -Password <string> -ServiceName <string> -Windows [-AffinityGroup <string>] [-AvailabilitySetName <string>] [-Certificates <CertificateSettingList>] [-DisableWinRMHttps] [-DnsSettings <DnsServer[]>] [-EnableWinRMHttp] [-HostCaching <string>] [-InstanceSize <string>] [-Location <string>] [-MediaLocation <string>] [-Name <string>] [-NoExportPrivateKey] [-NoWinRMEndpoint] [-SubnetNames <string[]>] [-VNetName <string>] [-WaitForBoot] [-WinRMCertificate <X509Certificate2>] [-X509Certificates <X509Certificate2[]>] [<CommonParameters>] DESCRIPTION The New-AzureQuickVM sets the configuration for a new virtual machine and creates the virtual machine. It can create a new Windows Azure service, or deploy the new virtual machine into an existing service if neither -Location or -AffinityGroup is specified. LIENS CONNEXES Get-AzureVM New-AzureVMConfig Remove-AzureVM New-AzureVM
Like you see it’s possible to deploy a linux VM if you use -Linux switch 😉
New-AzureQuickVM -Windows -ServiceName pwrshell-lab -Name SRVTEST1 ` -ImageName (Get-AzureVMImage | ? label -like "*Windows Server 2012 Datacenter*")[0].ImageName ` -AdminUsername Benduru -Password P4ssw0rd -AffinityGroup PWRSHELL ` -InstanceSize Small
This will deploy a VM from a VHD in no time. Keep in mind that you’ll have to specify a new ServiceName each time !
Ok, we have now our VM, but i’m disapointed. No vm configuration.. the cmdlet is well named, it’s a quick configuration :). We’ll have to use more cmdlets to deploy a VM configured like we want:
- New-AzureVMConfig
- Add-AzureProvisioningConfig
- Set-AzureSubnet
How it works… First how to create a configuration object
New-AzureVMConfig -Name pwrshell-full -InstanceSize Small ` -ImageName (Get-AzureVMImage | ? label -like "*Windows Server 2012 Datacenter*")[0].ImageName -DiskName OSDisk
Ok, once the configuration is created, let’s use the Add-AzureProvisioningConfig cmdlet to add the login/password for the Administrator and specify if it’s a Windows or Linux VM in the configuration object. With this cmdlet you can join and Active Directory and create the Server into a specific OU, you can disable RDP or WinRM. I suggest you to read the man, this is a very powerfull cmdlet. Also, we’ll take a look in a futur post about create/configure an domain and automaticly join a new VM in the domain.
Add-AzureProvisioningConfig -Windows -Password P4ssw0rd -AdminUsername Benduru
We have prepared our configuration, let’s specify the subnet of our VM.
Set-AzureSubnet France
And now, how to use it together 🙂
New-AzureVMConfig -Name pwrshell-ok -InstanceSize Small ` -ImageName (Get-AzureVMImage | ? label -like "*Windows Server 2012 Datacenter*")[0].ImageName | ` Add-AzureProvisioningConfig -Windows -Password P4ssw0rd -AdminUsername Benduru | ` Set-AzureSubnet 'France' | ` New-AzureVM -ServiceName pwrshellxlab -AffinityGroup PWRSHELL -VNetName test
We have now our VM in our network 😀
Get-AzureVM ServiceName Name Status ----------- ---- ------ pwrshellxlab pwrshell-ok ReadyRole
That’s all for today, let’s see again in a futur post to explore the manipulation of your new VM.
Regards!