Skip to main content

virtual_machines

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

Overview

Namevirtual_machines
TypeResource
Idazure_extras.network_cloud.virtual_machines

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
adminUsernamestringThe name of the administrator to which the ssh public keys will be added into the authorized keys. Required.
availabilityZonestringThe cluster availability zone containing this virtual machine.
bareMetalMachineIdstringThe resource ID of the bare metal machine that hosts the virtual machine.
bootMethodstringSelects the boot method for the virtual machine. Known values are: "BIOS" and "UEFI". (BIOS, UEFI)
cloudServicesNetworkAttachmentobjectNetworkAttachment represents the single network attachment.
clusterIdstringThe resource ID of the cluster the virtual machine is created for.
consoleExtendedLocationobjectThe extended location to use for creation of a VM console resource.
cpuCoresintegerThe number of CPU cores in the virtual machine. Required.
detailedStatusstringThe more detailed status of the virtual machine. Known values are: "Available", "Error", "Provisioning", "Running", "Scheduling", "Stopped", "Terminating", and "Unknown". (Available, Error, Provisioning, Running, Scheduling, Stopped, Terminating, Unknown)
detailedStatusMessagestringThe descriptive message about the current detailed status.
etagstring"If etag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields.").
extendedLocationobjectThe extended location of the resource. This property is required when creating the resource. Required.
identityobjectThe managed service identities assigned to this resource.
isolateEmulatorThreadstringField Deprecated, the value will be ignored if provided. The indicator of whether one of the specified CPU cores is isolated to run the emulator thread for this virtual machine. Known values are: "False" and "True". (False, True)
locationstringThe geo-location where the resource lives. Required.
memorySizeGBintegerThe memory size of the virtual machine. Allocations are measured in gibibytes. Required.
networkAttachmentsarrayThe list of network attachments to the virtual machine.
networkDatastringField Deprecated: The Base64 encoded cloud-init network data. The networkDataContent property will be used in preference to this property.
networkDataContentstringThe Base64 encoded cloud-init network data.
placementHintsarrayThe scheduling hints for the virtual machine.
powerStatestringThe power state of the virtual machine. Known values are: "Off", "On", and "Unknown". (Off, On, Unknown)
provisioningStatestringThe provisioning state of the virtual machine. Known values are: "Accepted", "Canceled", "Failed", "Provisioning", and "Succeeded". (Accepted, Canceled, Failed, Provisioning, Succeeded)
sshPublicKeysarrayThe list of ssh public keys. Each key will be added to the virtual machine using the cloud-init ssh_authorized_keys mechanism for the adminUsername.
storageProfileobjectThe storage profile that specifies size and other parameters about the disks related to the virtual machine. Required.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
userDatastringField Deprecated: The Base64 encoded cloud-init user data. The userDataContent property will be used in preference to this property.
userDataContentstringThe Base64 encoded cloud-init user data.
virtioInterfacestringField Deprecated, use virtualizationModel instead. The type of the virtio interface. Known values are: "Modern" and "Transitional". (Modern, Transitional)
vmDeviceModelstringThe type of the device model to use. Known values are: "T1", "T2", and "T3". (T1, T2, T3)
vmImagestringThe virtual machine image that is currently provisioned to the OS disk, using the full url and tag notation used to pull the image. Required.
vmImageRepositoryCredentialsobjectThe credentials used to login to the image repository that has access to the specified image.
volumesarrayThe resource IDs of volumes that are attached to the virtual machine.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, virtual_machine_name, subscription_idGet properties of the provided virtual machine.
list_by_resource_groupselectresource_group_name, subscription_id$top, $skipTokenGet a list of virtual machines in the provided resource group.
list_by_subscriptionselectsubscription_id$top, $skipTokenGet a list of virtual machines in the provided subscription.
create_or_updateinsertresource_group_name, virtual_machine_name, subscription_id, location, properties, extendedLocationCreate a new virtual machine or update the properties of the existing virtual machine.
updateupdateresource_group_name, virtual_machine_name, subscription_idPatch the properties of the provided virtual machine, or update the tags associated with the virtual machine. Properties and tag updates can be done independently.
create_or_updatereplaceresource_group_name, virtual_machine_name, subscription_id, location, properties, extendedLocationCreate a new virtual machine or update the properties of the existing virtual machine.
deletedeleteresource_group_name, virtual_machine_name, subscription_idDelete the provided virtual machine.
assign_relayexecresource_group_name, virtual_machine_name, subscription_id, machineIdAssigns a relay to the specified Microsoft.HybridCompute machine associated with the provided virtual machine.
power_offexecresource_group_name, virtual_machine_name, subscription_idPower off the provided virtual machine.
reimageexecresource_group_name, virtual_machine_name, subscription_idReimage the provided virtual machine.
restartexecresource_group_name, virtual_machine_name, subscription_idRestart the provided virtual machine.
startexecresource_group_name, virtual_machine_name, subscription_idStart the provided virtual machine.

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
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
subscription_idstring
virtual_machine_namestringThe name of the virtual machine. Required.
$skipTokenstringThe opaque token that the server returns to indicate where to continue listing resources from. This is used for paging through large result sets. Default value is None.
$topintegerThe maximum number of resources to return from the operation. Example: '$top=10'. Default value is None.

SELECT examples

Get properties of the provided virtual machine.

SELECT
id,
name,
adminUsername,
availabilityZone,
bareMetalMachineId,
bootMethod,
cloudServicesNetworkAttachment,
clusterId,
consoleExtendedLocation,
cpuCores,
detailedStatus,
detailedStatusMessage,
etag,
extendedLocation,
identity,
isolateEmulatorThread,
location,
memorySizeGB,
networkAttachments,
networkData,
networkDataContent,
placementHints,
powerState,
provisioningState,
sshPublicKeys,
storageProfile,
systemData,
tags,
type,
userData,
userDataContent,
virtioInterface,
vmDeviceModel,
vmImage,
vmImageRepositoryCredentials,
volumes
FROM azure_extras.network_cloud.virtual_machines
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND virtual_machine_name = '{{ virtual_machine_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

INSERT examples

Create a new virtual machine or update the properties of the existing virtual machine.

INSERT INTO azure_extras.network_cloud.virtual_machines (
tags,
location,
properties,
extendedLocation,
identity,
resource_group_name,
virtual_machine_name,
subscription_id
)
SELECT
'{{ tags }}',
'{{ location }}' /* required */,
'{{ properties }}' /* required */,
'{{ extendedLocation }}' /* required */,
'{{ identity }}',
'{{ resource_group_name }}',
'{{ virtual_machine_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
etag,
extendedLocation,
identity,
location,
properties,
systemData,
tags,
type
;

UPDATE examples

Patch the properties of the provided virtual machine, or update the tags associated with the virtual machine. Properties and tag updates can be done independently.

UPDATE azure_extras.network_cloud.virtual_machines
SET
identity = '{{ identity }}',
properties = '{{ properties }}',
tags = '{{ tags }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND virtual_machine_name = '{{ virtual_machine_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
etag,
extendedLocation,
identity,
location,
properties,
systemData,
tags,
type;

REPLACE examples

Create a new virtual machine or update the properties of the existing virtual machine.

REPLACE azure_extras.network_cloud.virtual_machines
SET
tags = '{{ tags }}',
location = '{{ location }}',
properties = '{{ properties }}',
extendedLocation = '{{ extendedLocation }}',
identity = '{{ identity }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND virtual_machine_name = '{{ virtual_machine_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND location = '{{ location }}' --required
AND properties = '{{ properties }}' --required
AND extendedLocation = '{{ extendedLocation }}' --required
RETURNING
id,
name,
etag,
extendedLocation,
identity,
location,
properties,
systemData,
tags,
type;

DELETE examples

Delete the provided virtual machine.

DELETE FROM azure_extras.network_cloud.virtual_machines
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND virtual_machine_name = '{{ virtual_machine_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;

Lifecycle Methods

Assigns a relay to the specified Microsoft.HybridCompute machine associated with the provided virtual machine.

EXEC azure_extras.network_cloud.virtual_machines.assign_relay 
@resource_group_name='{{ resource_group_name }}' --required,
@virtual_machine_name='{{ virtual_machine_name }}' --required,
@subscription_id='{{ subscription_id }}' --required
@@json=
'{
"machineId": "{{ machineId }}",
"relayType": "{{ relayType }}"
}'
;