Skip to main content

disks

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

Overview

Namedisks
TypeResource
Idazure.compute.disks

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringResource Id
namestringResource name
extendedLocationobjectThe extended location where the disk will be created. Extended location cannot be changed.
locationstringResource location
managedBystringA relative URI containing the ID of the VM that has the disk attached.
managedByExtendedarrayList of relative URIs containing the IDs of the VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs.
propertiesobjectDisk resource properties.
skuobjectThe disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS.
tagsobjectResource tags
typestringResource type
zonesarrayThe Logical zone list for Disk.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsubscriptionId, resourceGroupName, diskNameGets information about a disk.
list_by_resource_groupselectsubscriptionId, resourceGroupNameLists all the disks under a resource group.
listselectsubscriptionIdLists all the disks under a subscription.
create_or_updateinsertsubscriptionId, resourceGroupName, diskNameCreates or updates a disk.
updateupdatesubscriptionId, resourceGroupName, diskNameUpdates (patches) a disk.
deletedeletesubscriptionId, resourceGroupName, diskNameDeletes a disk.
grant_accessexecsubscriptionId, resourceGroupName, diskName, access, durationInSecondsGrants access to a disk.
revoke_accessexecsubscriptionId, resourceGroupName, diskNameRevokes access to a disk.

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
diskNamestringThe name of the managed disk that is being created. The name can't be changed after the disk is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters.
resourceGroupNamestringThe name of the resource group.
subscriptionIdstringSubscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.

SELECT examples

Gets information about a disk.

SELECT
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
tags,
type,
zones
FROM azure.compute.disks
WHERE subscriptionId = '{{ subscriptionId }}' -- required
AND resourceGroupName = '{{ resourceGroupName }}' -- required
AND diskName = '{{ diskName }}' -- required
;

INSERT examples

Creates or updates a disk.

INSERT INTO azure.compute.disks (
data__sku,
data__zones,
data__extendedLocation,
data__properties,
data__location,
data__tags,
subscriptionId,
resourceGroupName,
diskName
)
SELECT
'{{ sku }}',
'{{ zones }}',
'{{ extendedLocation }}',
'{{ properties }}',
'{{ location }}',
'{{ tags }}',
'{{ subscriptionId }}',
'{{ resourceGroupName }}',
'{{ diskName }}'
RETURNING
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
tags,
type,
zones
;

UPDATE examples

Updates (patches) a disk.

UPDATE azure.compute.disks
SET
data__properties = '{{ properties }}',
data__tags = '{{ tags }}',
data__sku = '{{ sku }}'
WHERE
subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND diskName = '{{ diskName }}' --required
RETURNING
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
tags,
type,
zones;

DELETE examples

Deletes a disk.

DELETE FROM azure.compute.disks
WHERE subscriptionId = '{{ subscriptionId }}' --required
AND resourceGroupName = '{{ resourceGroupName }}' --required
AND diskName = '{{ diskName }}' --required
;

Lifecycle Methods

Grants access to a disk.

EXEC azure.compute.disks.grant_access 
@subscriptionId='{{ subscriptionId }}' --required,
@resourceGroupName='{{ resourceGroupName }}' --required,
@diskName='{{ diskName }}' --required
@@json=
'{
"access": "{{ access }}",
"durationInSeconds": {{ durationInSeconds }},
"getSecureVMGuestStateSAS": {{ getSecureVMGuestStateSAS }},
"fileFormat": "{{ fileFormat }}"
}'
;