New-AzVMConfig

Creates a configurable virtual machine object.

Syntax

New-AzVMConfig
   [-VMName] <String>
   [-VMSize] <String>
   [[-AvailabilitySetId] <String>]
   [[-LicenseType] <String>]
   [-Zone <String[]>]
   [-ProximityPlacementGroupId <String>]
   [-HostId <String>]
   [-VmssId <String>]
   [-MaxPrice <Double>]
   [-EvictionPolicy <String>]
   [-Priority <String>]
   [-Tags <Hashtable>]
   [-EnableUltraSSD]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzVMConfig
   [-VMName] <String>
   [-VMSize] <String>
   [[-AvailabilitySetId] <String>]
   [[-LicenseType] <String>]
   [-IdentityType] <ResourceIdentityType>
   [-IdentityId <String[]>]
   [-Zone <String[]>]
   [-ProximityPlacementGroupId <String>]
   [-HostId <String>]
   [-VmssId <String>]
   [-MaxPrice <Double>]
   [-EvictionPolicy <String>]
   [-Priority <String>]
   [-Tags <Hashtable>]
   [-EnableUltraSSD]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzVMConfig cmdlet creates a configurable local virtual machine object for Azure. Other cmdlets can be used to configure a virtual machine object, such as Set-AzVMOperatingSystem, Set-AzVMSourceImage, Add-AzVMNetworkInterface, and Set-AzVMOSDisk.

Examples

Example 1: Create a virtual machine object

PS C:\> $AvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"
PS C:\> $VirtualMachine = New-AzVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id

The first command gets the availability set named AvailabilitySet03 in the resource group named ResourceGroup11, and then stores that object in the $AvailabilitySet variable. The second command creates a virtual machine object, and then stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet.

Parameters

-AvailabilitySetId

Specifies the ID of an availability set. To obtain an availability set object, use the Get-AzAvailabilitySet cmdlet. The availability set object contains an ID property.
Virtual machines specified in the same availability set are allocated to different nodes to maximize availability.
For more information about availability sets, see Manage the availability of virtual machines.
For more information on Azure planned maintenance, see Planned maintenance for virtual machines in Azure
Currently, a VM can only be added to availability set at creation time. The availability set to which the VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set.
This property cannot exist along with a non-null properties.virtualMachineScaleSet reference.

Type:String
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-EnableUltraSSD

Enables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine only if this property is enabled.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-EvictionPolicy

The eviction policy for the Azure Spot virtual machine. Supported values are 'Deallocate' and 'Delete'.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-HostId

The Id of Host

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-IdentityId

Specifies the list of user identities associated with the virtual machine scale set. The user identity references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/identities/{identityName}'

Type:System.String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-IdentityType

The identity of the virtual machine, if configured.

Type:System.Nullable`1[Microsoft.Azure.Management.Compute.Models.ResourceIdentityType]
Accepted values:SystemAssigned, UserAssigned, SystemAssignedUserAssigned, None
Position:4
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-LicenseType

The license type, which is for bringing your own license scenario.

Type:String
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-MaxPrice

Specifies the maximum price you are willing to pay for a low priority VM/VMSS. This price is in US Dollars. This price will be compared with the current low priority price for the VM size. Also, the prices are compared at the time of create/update of low priority VM/VMSS and the operation will only succeed if the maxPrice is greater than the current low priority price. The maxPrice will also be used for evicting a low priority VM/VMSS if the current low priority price goes beyond the maxPrice after creation of VM/VMSS. Possible values are: any decimal value greater than zero. Example: 0.01538. -1 indicates that the low priority VM/VMSS should not be evicted for price reasons. Also, the default max price is -1 if it is not provided by you.

Type:Double
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Priority

The priority for the virtual machine. Only supported values are 'Regular', 'Spot' and 'Low'. 'Regular' is for regular virtual machine. 'Spot' is for spot virtual machine. 'Low' is also for spot virtual machine but is replaced by 'Spot'. Please use 'Spot' instead of 'Low'.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ProximityPlacementGroupId

The resource id of the Proximity Placement Group to use with this virtual machine.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Tags

The tags attached to the resource.

Type:Hashtable
Aliases:Tag
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VMName

Specifies a name for the virtual machine.

Type:String
Aliases:ResourceName, Name
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VMSize

Specifies the size for the virtual machine.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VmssId

The Id of virtual machine scale set

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Zone

Specifies the availability zone list for the virtual machine. The allowed values depend on the capabilities of the region. Allowed values will normally be 1,2,3.

Type:System.String[]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Inputs

String

System.String[]

Hashtable

SwitchParameter

Outputs

PSVirtualMachine