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.
locationstringThe location of the resource.
propertiesobjectThe properties of the resource.
tagsobjectThe tags of the resource.
typestringThe type of the resource.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsubscriptionId, resourceGroupName, labName, name$expand, api-versionGet virtual machine.
listselectsubscriptionId, resourceGroupName, labName$expand, $filter, $top, $orderby, api-versionList virtual machines in a given lab.
create_or_updateinsertsubscriptionId, resourceGroupName, labName, name, data__propertiesapi-versionCreate or replace an existing virtual machine. This operation can take a while to complete.
updateupdatesubscriptionId, resourceGroupName, labName, nameapi-versionAllows modifying tags of virtual machines. All other properties will be ignored.
deletedeletesubscriptionId, resourceGroupName, labName, nameapi-versionDelete virtual machine. This operation can take a while to complete.
add_data_diskexecsubscriptionId, resourceGroupName, labName, nameapi-versionAttach a new or existing data disk to virtual machine. This operation can take a while to complete.
apply_artifactsexecsubscriptionId, resourceGroupName, labName, nameapi-versionApply artifacts to virtual machine. This operation can take a while to complete.
claimexecsubscriptionId, resourceGroupName, labName, nameapi-versionTake ownership of an existing virtual machine This operation can take a while to complete.
detach_data_diskexecsubscriptionId, resourceGroupName, labName, nameapi-versionDetach the specified disk from the virtual machine. This operation can take a while to complete.
redeployexecsubscriptionId, resourceGroupName, labName, nameapi-versionRedeploy a virtual machine This operation can take a while to complete.
resizeexecsubscriptionId, resourceGroupName, labName, nameapi-versionResize Virtual Machine. This operation can take a while to complete.
restartexecsubscriptionId, resourceGroupName, labName, nameapi-versionRestart a virtual machine. This operation can take a while to complete.
startexecsubscriptionId, resourceGroupName, labName, nameapi-versionStart a virtual machine. This operation can take a while to complete.
stopexecsubscriptionId, resourceGroupName, labName, nameapi-versionStop a virtual machine This operation can take a while to complete.
transfer_disksexecsubscriptionId, resourceGroupName, labName, nameapi-versionTransfers all data disks attached to the virtual machine to be owned by the current user. This operation can take a while to complete.
un_claimexecsubscriptionId, resourceGroupName, labName, nameapi-versionRelease 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
labNamestringThe name of the lab.
namestringThe name of the virtual machine.
resourceGroupNamestringThe name of the resource group.
subscriptionIdstringThe subscription ID.
$expandstringSpecify the $expand query. Example: 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
$filterstringThe filter to apply to the operation. Example: '$filter=contains(name,'myName')
$orderbystringThe ordering expression for the results, using OData notation. Example: '$orderby=name desc'
$topinteger (int32)The maximum number of resources to return from the operation. Example: '$top=10'
api-versionstringClient API version.

SELECT examples

Get virtual machine.

SELECT
id,
name,
location,
properties,
tags,
type
FROM azure.dev_test_labs.virtual_machines
WHERE subscriptionId = '{{ subscriptionId }}' -- required
AND resourceGroupName = '{{ resourceGroupName }}' -- required
AND labName = '{{ labName }}' -- required
AND name = '{{ name }}' -- required
AND $expand = '{{ $expand }}'
AND api-version = '{{ api-version }}'
;

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 (
data__location,
data__tags,
data__properties,
subscriptionId,
resourceGroupName,
labName,
name,
api-version
)
SELECT
'{{ location }}',
'{{ tags }}',
'{{ properties }}' /* required */,
'{{ subscriptionId }}',
'{{ resourceGroupName }}',
'{{ labName }}',
'{{ name }}',
'{{ api-version }}'
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
data__tags = '{{ tags }}'
WHERE
subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND labName = '{{ labName }}' --required
AND name = '{{ name }}' --required
AND api-version = '{{ api-version}}'
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 subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND labName = '{{ labName }}' --required
AND name = '{{ name }}' --required
AND api-version = '{{ api-version }}'
;

Lifecycle Methods

Attach a new or existing data disk to virtual machine. This operation can take a while to complete.

EXEC azure.dev_test_labs.virtual_machines.add_data_disk 
@subscriptionId='{{ subscriptionId }}' --required,
@resourceGroupName='{{ resourceGroupName }}' --required,
@labName='{{ labName }}' --required,
@name='{{ name }}' --required,
@api-version='{{ api-version }}'
@@json=
'{
"attachNewDataDiskOptions": "{{ attachNewDataDiskOptions }}",
"existingLabDiskId": "{{ existingLabDiskId }}",
"hostCaching": "{{ hostCaching }}"
}'
;