Skip to main content

virtual_machines

Creates, updates, deletes, gets or lists a virtual_machines resource.

Overview

Namevirtual_machines
TypeResource
Idazure.dev_test_labs.virtual_machines

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier of the resource.
namestringThe name of the resource.
allowClaimbooleanIndicates whether another user can take ownership of the virtual machine.
applicableScheduleobjectThe applicable schedule for the virtual machine.
artifactDeploymentStatusobjectThe artifact deployment status for the virtual machine.
artifactsarrayThe artifacts to be installed on the virtual machine.
computeIdstringThe resource identifier (Microsoft.Compute) of the virtual machine.
computeVmobjectThe compute virtual machine properties.
createdByUserstringThe email address of creator of the virtual machine.
createdByUserIdstringThe object identifier of the creator of the virtual machine.
createdDatestring (date-time)The creation date of the virtual machine.
customImageIdstringThe custom image identifier of the virtual machine.
dataDiskParametersarrayNew or existing data disks to attach to the virtual machine after creation.
disallowPublicIpAddressbooleanIndicates whether the virtual machine is to be created without a public IP address.
environmentIdstringThe resource ID of the environment that contains this virtual machine, if any.
expirationDatestring (date-time)The expiration date for VM.
fqdnstringThe fully-qualified domain name of the virtual machine.
galleryImageReferenceobjectThe Microsoft Azure Marketplace image reference of the virtual machine.
isAuthenticationWithSshKeybooleanIndicates whether this virtual machine uses an SSH key for authentication.
labSubnetNamestringThe lab subnet name of the virtual machine.
labVirtualNetworkIdstringThe lab virtual network identifier of the virtual machine.
lastKnownPowerStatestringLast known compute power state captured in DTL.
locationstringThe location of the resource.
networkInterfaceobjectThe network interface properties.
notesstringThe notes of the virtual machine.
osTypestringThe OS type of the virtual machine.
ownerObjectIdstringThe object identifier of the owner of the virtual machine.
ownerUserPrincipalNamestringThe user principal name of the virtual machine owner.
passwordstringThe password of the virtual machine administrator.
planIdstringThe id of the plan associated with the virtual machine image.
provisioningStatestringThe provisioning status of the resource.
scheduleParametersarrayVirtual Machine schedules to be created.
sizestringThe size of the virtual machine.
sshKeystringThe SSH key of the virtual machine administrator.
storageTypestringStorage type to use for virtual machine (i.e. Standard, Premium).
tagsobjectThe tags of the resource.
typestringThe type of the resource.
uniqueIdentifierstringThe unique immutable identifier of a resource (Guid).
userNamestringThe user name of the virtual machine.
virtualMachineCreationSourcestringTells source of creation of lab virtual machine. Output property only. Known values are: "FromCustomImage", "FromGalleryImage", and "FromSharedGalleryImage".

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, lab_name, name, subscription_id$expandGet virtual machine.
listselectresource_group_name, lab_name, subscription_id$expand, $filter, $top, $orderbyList virtual machines in a given lab.
create_or_updateinsertresource_group_name, lab_name, name, subscription_idCreate or replace an existing virtual machine. This operation can take a while to complete.
updateupdateresource_group_name, lab_name, name, subscription_idAllows modifying tags of virtual machines. All other properties will be ignored.
create_or_updatereplaceresource_group_name, lab_name, name, subscription_idCreate or replace an existing virtual machine. This operation can take a while to complete.
deletedeleteresource_group_name, lab_name, name, subscription_idDelete virtual machine. This operation can take a while to complete.
list_applicable_schedulesexecresource_group_name, lab_name, name, subscription_idLists the applicable start/stop schedules, if any.
get_rdp_file_contentsexecresource_group_name, lab_name, name, subscription_idGets a string that represents the contents of the RDP file for the virtual machine.
add_data_diskexecresource_group_name, lab_name, name, subscription_idAttach a new or existing data disk to virtual machine. This operation can take a while to complete.
apply_artifactsexecresource_group_name, lab_name, name, subscription_idApply artifacts to virtual machine. This operation can take a while to complete.
claimexecresource_group_name, lab_name, name, subscription_idTake ownership of an existing virtual machine This operation can take a while to complete.
detach_data_diskexecresource_group_name, lab_name, name, subscription_idDetach the specified disk from the virtual machine. This operation can take a while to complete.
redeployexecresource_group_name, lab_name, name, subscription_idRedeploy a virtual machine This operation can take a while to complete.
resizeexecresource_group_name, lab_name, name, subscription_idResize Virtual Machine. This operation can take a while to complete.
restartexecresource_group_name, lab_name, name, subscription_idRestart a virtual machine. This operation can take a while to complete.
startexecresource_group_name, lab_name, name, subscription_idStart a virtual machine. This operation can take a while to complete.
stopexecresource_group_name, lab_name, name, subscription_idStop a virtual machine This operation can take a while to complete.
transfer_disksexecresource_group_name, lab_name, name, subscription_idTransfers all data disks attached to the virtual machine to be owned by the current user. This operation can take a while to complete.
un_claimexecresource_group_name, lab_name, name, subscription_idRelease ownership of an existing virtual machine This operation can take a while to complete.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
lab_namestringThe name of the lab. Required.
namestringThe name of the virtual machine. Required.
resource_group_namestringThe name of the resource group. Required.
subscription_idstring
$expandstringSpecify the $expand query. Example: 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'. Default value is None.
$filterstringThe filter to apply to the operation. Example: '$filter=contains(name,'myName'). Default value is None.
$orderbystringThe ordering expression for the results, using OData notation. Example: '$orderby=name desc'. Default value is None.
$topintegerThe maximum number of resources to return from the operation. Example: '$top=10'. Default value is None.

SELECT examples

Get virtual machine.

SELECT
id,
name,
allowClaim,
applicableSchedule,
artifactDeploymentStatus,
artifacts,
computeId,
computeVm,
createdByUser,
createdByUserId,
createdDate,
customImageId,
dataDiskParameters,
disallowPublicIpAddress,
environmentId,
expirationDate,
fqdn,
galleryImageReference,
isAuthenticationWithSshKey,
labSubnetName,
labVirtualNetworkId,
lastKnownPowerState,
location,
networkInterface,
notes,
osType,
ownerObjectId,
ownerUserPrincipalName,
password,
planId,
provisioningState,
scheduleParameters,
size,
sshKey,
storageType,
tags,
type,
uniqueIdentifier,
userName,
virtualMachineCreationSource
FROM azure.dev_test_labs.virtual_machines
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND lab_name = '{{ lab_name }}' -- required
AND name = '{{ name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
AND $expand = '{{ $expand }}'
;

INSERT examples

Create or replace an existing virtual machine. This operation can take a while to complete.

INSERT INTO azure.dev_test_labs.virtual_machines (
location,
tags,
properties,
resource_group_name,
lab_name,
name,
subscription_id
)
SELECT
'{{ location }}',
'{{ tags }}',
'{{ properties }}',
'{{ resource_group_name }}',
'{{ lab_name }}',
'{{ name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
location,
properties,
tags,
type
;

UPDATE examples

Allows modifying tags of virtual machines. All other properties will be ignored.

UPDATE azure.dev_test_labs.virtual_machines
SET
-- No updatable properties
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
location,
properties,
tags,
type;

REPLACE examples

Create or replace an existing virtual machine. This operation can take a while to complete.

REPLACE azure.dev_test_labs.virtual_machines
SET
location = '{{ location }}',
tags = '{{ tags }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
location,
properties,
tags,
type;

DELETE examples

Delete virtual machine. This operation can take a while to complete.

DELETE FROM azure.dev_test_labs.virtual_machines
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND lab_name = '{{ lab_name }}' --required
AND name = '{{ name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;

Lifecycle Methods

Lists the applicable start/stop schedules, if any.

EXEC azure.dev_test_labs.virtual_machines.list_applicable_schedules 
@resource_group_name='{{ resource_group_name }}' --required,
@lab_name='{{ lab_name }}' --required,
@name='{{ name }}' --required,
@subscription_id='{{ subscription_id }}' --required
;