Skip to main content

disks

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

Overview

Namedisks
TypeResource
Idazure.dev_test_labs.disks

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, userName, name$expand, api-versionGet disk.
listselectsubscriptionId, resourceGroupName, labName, userName$expand, $filter, $top, $orderby, api-versionList disks in a given user profile.
create_or_updateinsertsubscriptionId, resourceGroupName, labName, userName, name, data__propertiesapi-versionCreate or replace an existing disk. This operation can take a while to complete.
updateupdatesubscriptionId, resourceGroupName, labName, userName, nameapi-versionAllows modifying tags of disks. All other properties will be ignored.
deletedeletesubscriptionId, resourceGroupName, labName, userName, nameapi-versionDelete disk. This operation can take a while to complete.
attachexecsubscriptionId, resourceGroupName, labName, userName, nameapi-versionAttach and create the lease of the disk to the virtual machine. This operation can take a while to complete.
detachexecsubscriptionId, resourceGroupName, labName, userName, nameapi-versionDetach and break the lease of the disk attached to the 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 disk.
resourceGroupNamestringThe name of the resource group.
subscriptionIdstringThe subscription ID.
userNamestringThe name of the user profile.
$expandstringSpecify the $expand query. Example: 'properties($select=diskType)'
$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 disk.

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

INSERT examples

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

INSERT INTO azure.dev_test_labs.disks (
data__location,
data__tags,
data__properties,
subscriptionId,
resourceGroupName,
labName,
userName,
name,
api-version
)
SELECT
'{{ location }}',
'{{ tags }}',
'{{ properties }}' /* required */,
'{{ subscriptionId }}',
'{{ resourceGroupName }}',
'{{ labName }}',
'{{ userName }}',
'{{ name }}',
'{{ api-version }}'
RETURNING
id,
name,
location,
properties,
tags,
type
;

UPDATE examples

Allows modifying tags of disks. All other properties will be ignored.

UPDATE azure.dev_test_labs.disks
SET
data__tags = '{{ tags }}'
WHERE
subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND labName = '{{ labName }}' --required
AND userName = '{{ userName }}' --required
AND name = '{{ name }}' --required
AND api-version = '{{ api-version}}'
RETURNING
id,
name,
location,
properties,
tags,
type;

DELETE examples

Delete disk. This operation can take a while to complete.

DELETE FROM azure.dev_test_labs.disks
WHERE subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND labName = '{{ labName }}' --required
AND userName = '{{ userName }}' --required
AND name = '{{ name }}' --required
AND api-version = '{{ api-version }}'
;

Lifecycle Methods

Attach and create the lease of the disk to the virtual machine. This operation can take a while to complete.

EXEC azure.dev_test_labs.disks.attach 
@subscriptionId='{{ subscriptionId }}' --required,
@resourceGroupName='{{ resourceGroupName }}' --required,
@labName='{{ labName }}' --required,
@userName='{{ userName }}' --required,
@name='{{ name }}' --required,
@api-version='{{ api-version }}'
@@json=
'{
"leasedByLabVmId": "{{ leasedByLabVmId }}"
}'
;