Skip to content

Commit cc604cf

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#6655 from da5is/patch-1
Added 3rd Example to New-AzureRMVM Documentation
2 parents 88b31b9 + da7a996 commit cc604cf

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/ResourceManager/Compute/Commands.Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Add example for `New-AzureRmVM`
2122
* Updated help files to include full parameter types.
2223

2324
## Version 5.3.0

src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,40 @@ This script can be used for automatic provisioning because it uses the local vir
134134
This script assumes that you are already logged into your Azure account.
135135
You can confirm your login status by using the **Get-AzureSubscription** cmdlet.
136136

137+
### Example 3: Create a VM from a marketplace image without a Public IP
138+
```
139+
$VMLocalAdminUser = "LocalAdminUser"
140+
$VMLocalAdminSecurePassword = ConvertTo-SecureString <password> -AsPlainText -Force
141+
$LocationName = "westus"
142+
$ResourceGroupName = "MyResourceGroup"
143+
$ComputerName = "MyVM"
144+
$VMName = "MyVM"
145+
$VMSize = "Standard_DS3"
146+
147+
$NetworkName = "MyNet"
148+
$NICName = "MyNIC"
149+
$SubnetName = "MySubnet"
150+
$SubnetAddressPrefix = "10.0.0.0/24"
151+
$VnetAddressPrefix = "10.0.0.0/16"
152+
153+
$SingleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix
154+
$Vnet = New-AzureRmVirtualNetwork -Name $NetworkName -ResourceGroupName $ResourceGroupName -Location $LocationName -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet
155+
$NIC = New-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $ResourceGroupName -Location $LocationName -SubnetId $Vnet.Subnets[0].Id
156+
157+
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $VMLocalAdminSecurePassword);
158+
159+
$VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
160+
$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
161+
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
162+
$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2012-R2-Datacenter' -Version latest
163+
164+
New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $VirtualMachine -Verbose
165+
```
166+
167+
This example provisions a new network and deploys a Windows VM from the Marketplace without creating a public IP address or Network Security Group.
168+
169+
This script can be used for automatic provisioning because it uses the local virtual machine admin credentials inline instead of calling **Get-Credential** which requires user interaction.
170+
137171
## PARAMETERS
138172

139173
### -AddressPrefix

0 commit comments

Comments
 (0)