Skip to content

Commit

Permalink
Merge branch 'sergey-entity' of https://github.com/sergey-shandar/azu…
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Nov 30, 2017
2 parents bcb9a26 + 56a843d commit bda3fba
Showing 1 changed file with 226 additions and 55 deletions.
281 changes: 226 additions & 55 deletions src/ResourceManager/Compute/Commands.Compute/help/New-AzureRmVM.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
external help file: Microsoft.Azure.Commands.Compute.dll-Help.xml
ms.assetid: 05E6155D-4F0E-406B-9312-77AD97EF66EE
online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/new-azurermvm
Expand All @@ -12,69 +12,35 @@ Creates a virtual machine.

## SYNTAX

### DefaultParameterSet (Default)
```
New-AzureRmVM [-ResourceGroupName] <String> [-Location] <String> [-VM] <PSVirtualMachine> [[-Zone] <String[]>]
[-DisableBginfoExtension] [-Tags <Hashtable>] [-LicenseType <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### StrategyParameterSet
```
New-AzureRmVM [[-ResourceGroupName] <String>] [[-Location] <String>] -Name <String> -Credential <PSCredential>
[-VirtualNetworkName <String>] [-AddressPrefix <String>] [-SubnetName <String>]
[-SubnetAddressPrefix <String>] [-PublicIpAddressName <String>] [-DomainNameLabel <String>]
[-AllocationMethod <String>] [-SecurityGroupName <String>] [-OpenPorts <Int32[]>] [-ImageName <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
The **New-AzureRmVM** cmdlet creates a virtual machine in Azure.
This cmdlet takes a virtual machine object as input.
Use the New-AzureRmVMConfig cmdlet to create a virtual machine object.
Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmVMOperatingSystem, Set-AzureRmVMSourceImage, Add-AzureRmVMNetworkInterface, and Set-AzureRmVMOSDisk.

The `StrategyParameterSet` provides a convenient method to create a VM by making common VM creation arguments optional.

## EXAMPLES

### Example 1: Create a virtual machine
```
PS C:\> # Variables
## Global
$ResourceGroupName = "ResourceGroup11"
$Location = "WestEurope"
## Storage
$StorageName = "generalstorage6cc"
$StorageType = "Standard_GRS"
## Network
$InterfaceName = "ServerInterface06"
$Subnet1Name = "Subnet1"
$VNetName = "VNet09"
$VNetAddressPrefix = "10.0.0.0/16"
$VNetSubnetAddressPrefix = "10.0.0.0/24"
## Compute
$VMName = "VirtualMachine12"
$ComputerName = "Server22"
$VMSize = "Standard_A2"
$OSDiskName = $VMName + "OSDisk"
# Resource Group
New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location
# Storage
$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageName -Type $StorageType -Location $Location
# Network
$PIp = New-AzureRmPublicIpAddress -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic
$SubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $Subnet1Name -AddressPrefix $VNetSubnetAddressPrefix
$VNet = New-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $SubnetConfig
$Interface = New-AzureRmNetworkInterface -Name $InterfaceName -ResourceGroupName $ResourceGroupName -Location $Location -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $PIp.Id
# Compute
## Setup local VM object
$Credential = Get-Credential
$VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $Interface.Id
$OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd"
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -CreateOption FromImage
## Create the VM in Azure
New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VirtualMachine
PS C:\> New-AzureRmVM -Name MyVm
```

This example script shows how to create a virtual machine.
Expand Down Expand Up @@ -138,6 +104,52 @@ You can confirm your login status by using the **Get-AzureSubscription** cmdlet.

## PARAMETERS

### -AddressPrefix
The address prefix for the virtual network which will be created for the VM.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:

Required: False
Position: Named
Default value: 192.168.0.0/16
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllocationMethod
The IP allocation method for the public IP which will be created for the VM.
```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Accepted values: Static, Dynamic

Required: False
Position: Named
Default value: Static
Accept pipeline input: False
Accept wildcard characters: False
```
### -Credential
The administrator credentials for the VM.
```yaml
Type: PSCredential
Parameter Sets: StrategyParameterSet
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Expand All @@ -158,7 +170,22 @@ Indicates that this cmdlet does not install the **BG Info** extension on the vir
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DomainNameLabel
The subdomain label for the fully-qualified domain name (FQDN) of the VM. This will take the form `{domainNameLabel}.{location}.cloudapp.azure.com`.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Expand All @@ -168,6 +195,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ImageName
The friendly image name upon which the VM will be built. These include: Win2016Datacenter, Win2012R2Datacenter, Win2012Datacenter, Win2008R2SP1, UbuntuLTS, CentOS, CoreOS, Debian, openSUSE-Leap, RHEL, SLES.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: Win2016Datacenter
Accept pipeline input: False
Accept wildcard characters: False
```

### -LicenseType
Specifies a license type, which indicates that the image or disk for the virtual machine was licensed on-premises.
This value is used only for images that contain the Windows Server operating system.
Expand All @@ -181,7 +223,7 @@ If you specify this parameter for an update, the value must match the initial va

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:
Required: False
Expand All @@ -196,7 +238,7 @@ Specifies a location for the virtual machine.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:
Required: True
Expand All @@ -206,12 +248,69 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Name
The name of the VM resource.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -OpenPorts
A list of ports to open on the network security group (NSG) for the created VM. The default value depends on the type of image chosen (i.e., Windows: 3389, 5985 and Linux: 22).

```yaml
Type: Int32[]
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PublicIpAddressName
The name of a new (or existing) public IP address for the created VM to use. If not specified, a name will be generated.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResourceGroupName
Specifies the name of a resource group.

```yaml
Type: String
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:
Required: True
Expand All @@ -221,14 +320,71 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -SecurityGroupName
The name of a new (or existing) network security group (NSG) for the created VM to use. If not specified, a name will be generated.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -SubnetAddressPrefix
The address prefix for the subnet which will be created for the VM.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: 192.168.1.0/24
Accept pipeline input: False
Accept wildcard characters: False
```

### -SubnetName
The name of a new (or existing) subnet for the created VM to use. If not specified, a name will be generated.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Tags
Specifies that resources and resource groups can be tagged with a set of name-value pairs.
Adding tags to resources enables you to group resources together across resource groups and to create your own views.
Each resource or resource group can have a maximum of 15 tags.

```yaml
Type: Hashtable
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:
Required: False
Expand All @@ -238,14 +394,29 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -VirtualNetworkName
The name of a new (or existing) virtual network for the created VM to use. If not specified, a name will be generated.

```yaml
Type: String
Parameter Sets: StrategyParameterSet
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -VM
Specifies a local virtual machine to create.
To obtain a virtual machine object, use the New-AzureRmVMConfig cmdlet.
Other cmdlets can be used to configure the virtual machine, such as Set-AzureRmVMOperatingSystem, Set-AzureRmVMSourceImage, and Add-AzureRmVMNetworkInterface.

```yaml
Type: PSVirtualMachine
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases: VMProfile
Required: True
Expand All @@ -260,7 +431,7 @@ Specifies the zone list of the virtual machine.

```yaml
Type: String[]
Parameter Sets: (All)
Parameter Sets: DefaultParameterSet
Aliases:
Required: False
Expand Down

0 comments on commit bda3fba

Please sign in to comment.