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
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
LastOwnershipUpdateTimestring (date-time)The UTC time when the ownership state of the disk was last changed i.e., the time the disk was last attached or detached from a VM or the time when the VM to which the disk was attached was deallocated or started.
availabilityPolicyobjectDetermines how platform treats disk failures.
burstingEnabledbooleanSet to true to enable bursting beyond the provisioned performance target of the disk. Bursting is disabled by default. Does not apply to Ultra disks.
burstingEnabledTimestring (date-time)Latest time when bursting was last enabled on a disk.
completionPercentnumberPercentage complete for the background copy when a resource is created via the CopyStart operation.
creationDataobjectDisk source information. CreationData information cannot be changed after the disk has been created. Required.
dataAccessAuthModestringAdditional authentication requirements when exporting or uploading to a disk or snapshot. Known values are: "AzureActiveDirectory" and "None". (AzureActiveDirectory, None)
diskAccessIdstringARM id of the DiskAccess resource for using private endpoints on disks.
diskIOPSReadOnlyintegerThe total number of IOPS that will be allowed across all VMs mounting the shared disk as ReadOnly. One operation can transfer between 4k and 256k bytes.
diskIOPSReadWriteintegerThe number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.
diskMBpsReadOnlyintegerThe total throughput (MBps) that will be allowed across all VMs mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.
diskMBpsReadWriteintegerThe bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.
diskSizeBytesintegerThe size of the disk in bytes. This field is read only.
diskSizeGBintegerIf creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
diskStatestringThe state of the disk. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", and "ActiveUpload". (Unattached, Attached, Reserved, Frozen, ActiveSAS, ActiveSASFrozen, ReadyToUpload, ActiveUpload)
encryptionobjectEncryption property can be used to encrypt data at rest with customer managed keys or platform managed keys.
encryptionSettingsCollectionobjectEncryption settings collection used for Azure Disk Encryption, can contain multiple encryption settings per disk or snapshot.
extendedLocationobjectThe extended location where the disk will be created. Extended location cannot be changed.
hyperVGenerationstringThe hypervisor generation of the Virtual Machine. Applicable to OS disks only. Known values are: "V1" and "V2". (V1, V2)
locationstringThe geo-location where the resource lives. Required.
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.
maxSharesintegerThe maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time.
networkAccessPolicystringPolicy for accessing the disk via network. Known values are: "AllowAll", "AllowPrivate", and "DenyAll". (AllowAll, AllowPrivate, DenyAll)
optimizedForFrequentAttachbooleanSetting this property to true improves reliability and performance of data disks that are frequently (more than 5 times a day) by detached from one virtual machine and attached to another. This property should not be set for disks that are not detached and attached frequently as it causes the disks to not align with the fault domain of the virtual machine.
osTypestringThe Operating System type. Known values are: "Windows" and "Linux". (Windows, Linux)
propertyUpdatesInProgressobjectProperties of the disk for which update is pending.
provisioningStatestringThe disk provisioning state.
publicNetworkAccessstringPolicy for controlling export on the disk. Known values are: "Enabled" and "Disabled". (Enabled, Disabled)
purchasePlanobjectPurchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: WindowsServer}.
securityProfileobjectContains the security related information for the resource.
shareInfoarrayDetails of the list of all 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.
skuobjectThe disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS.
supportedCapabilitiesobjectList of supported capabilities for the image from which the OS disk was created.
supportsHibernationbooleanIndicates the OS on a disk supports hibernation.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
tierstringPerformance tier of the disk (e.g, P4, S10) as described here: https://azure.microsoft.com/en-us/pricing/details/managed-disks/ _. Does not apply to Ultra disks.
timeCreatedstring (date-time)The time when the disk was created.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
uniqueIdstringUnique Guid identifying the resource.
zonesarrayThe Logical zone list for Disk.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, disk_name, subscription_idGets information about a disk.
list_by_resource_groupselectresource_group_name, subscription_idLists all the disks under a resource group.
listselectsubscription_idLists all the disks under a subscription.
create_or_updateinsertresource_group_name, disk_name, subscription_id, locationCreates or updates a disk.
updateupdateresource_group_name, disk_name, subscription_idUpdates (patches) a disk.
create_or_updatereplaceresource_group_name, disk_name, subscription_id, locationCreates or updates a disk.
deletedeleteresource_group_name, disk_name, subscription_idDeletes a disk.
grant_accessexecresource_group_name, disk_name, subscription_id, access, durationInSecondsGrants access to a disk.
revoke_accessexecresource_group_name, disk_name, subscription_idRevokes 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
disk_namestringThe 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. Required.
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
subscription_idstring

SELECT examples

Gets information about a disk.

SELECT
id,
name,
LastOwnershipUpdateTime,
availabilityPolicy,
burstingEnabled,
burstingEnabledTime,
completionPercent,
creationData,
dataAccessAuthMode,
diskAccessId,
diskIOPSReadOnly,
diskIOPSReadWrite,
diskMBpsReadOnly,
diskMBpsReadWrite,
diskSizeBytes,
diskSizeGB,
diskState,
encryption,
encryptionSettingsCollection,
extendedLocation,
hyperVGeneration,
location,
managedBy,
managedByExtended,
maxShares,
networkAccessPolicy,
optimizedForFrequentAttach,
osType,
propertyUpdatesInProgress,
provisioningState,
publicNetworkAccess,
purchasePlan,
securityProfile,
shareInfo,
sku,
supportedCapabilities,
supportsHibernation,
systemData,
tags,
tier,
timeCreated,
type,
uniqueId,
zones
FROM azure.compute.disks
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND disk_name = '{{ disk_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

INSERT examples

Creates or updates a disk.

INSERT INTO azure.compute.disks (
tags,
location,
properties,
sku,
zones,
extendedLocation,
resource_group_name,
disk_name,
subscription_id
)
SELECT
'{{ tags }}',
'{{ location }}' /* required */,
'{{ properties }}',
'{{ sku }}',
'{{ zones }}',
'{{ extendedLocation }}',
'{{ resource_group_name }}',
'{{ disk_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
systemData,
tags,
type,
zones
;

UPDATE examples

Updates (patches) a disk.

UPDATE azure.compute.disks
SET
properties = '{{ properties }}',
tags = '{{ tags }}',
sku = '{{ sku }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND disk_name = '{{ disk_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
systemData,
tags,
type,
zones;

REPLACE examples

Creates or updates a disk.

REPLACE azure.compute.disks
SET
tags = '{{ tags }}',
location = '{{ location }}',
properties = '{{ properties }}',
sku = '{{ sku }}',
zones = '{{ zones }}',
extendedLocation = '{{ extendedLocation }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND disk_name = '{{ disk_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND location = '{{ location }}' --required
RETURNING
id,
name,
extendedLocation,
location,
managedBy,
managedByExtended,
properties,
sku,
systemData,
tags,
type,
zones;

DELETE examples

Deletes a disk.

DELETE FROM azure.compute.disks
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND disk_name = '{{ disk_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;

Lifecycle Methods

Grants access to a disk.

EXEC azure.compute.disks.grant_access 
@resource_group_name='{{ resource_group_name }}' --required,
@disk_name='{{ disk_name }}' --required,
@subscription_id='{{ subscription_id }}' --required
@@json=
'{
"access": "{{ access }}",
"durationInSeconds": {{ durationInSeconds }},
"getSecureVMGuestStateSAS": {{ getSecureVMGuestStateSAS }},
"fileFormat": "{{ fileFormat }}"
}'
;