π Azure Managed Disk is not attached to any Virtual Machine π’
- Contextual name: π Managed Disk is not attached to any Virtual Machine π’
- ID:
/ce/ca/azure/virtual-machine/unattached-managed-disk
- Located in: π Azure Virtual Machine
Flagsβ
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
Our Metadataβ
- Policy Type:
COMPLIANCE_POLICY
- Policy Category:
COST
Logicβ
- π§ prod.logic.yaml π’
Descriptionβ
Descriptionβ
Ensure that Azure Managed Disks not currently attached to any Virtual Machine are either deleted or transitioned to an appropriate archival state.
Rationaleβ
Unattached Managed Disks continue to accrue storage costs, resulting in avoidable cloud expenditure. Proactively identifying and managing these resources is essential for cost optimization and operational efficiency.
Moreover, the presence of unattached disks introduces unnecessary clutter within the Azure environment, complicating resource tracking and increasing administrative overhead.
Auditβ
This policy flags an Azure Managed Disk as
INCOMPLIANT
if theDisk State
is set to Unattached.
Remediationβ
Remediationβ
If the data stored on an unattached Managed Disk is no longer required, it is recommended to delete the disk to eliminate unnecessary costs. If the data must be preserved for archival or future use, consider creating a snapshot or image prior to deletion.
Delete the Unattached Managed Diskβ
Azure CLIβ
az disk delete --name {{disk-name}} \
--resource-group {{resource-group-name}}PowerShellβ
Remove-AzDisk -DiskName "{{disk-name}}" `
-ResourceGroupName "{{resource-group-name}}" -ForceArchive the Disk via Snapshotβ
Azure CLIβ
az snapshot create \
--resource-group {{resource-group-name}} \
--source {{resource-id-of-source-disk}} \
--name {{snapshot-name}} \
--sku {{Standard_LRS / Standard_ZRS}} \
--location {{snapshot-location}}PowerShellβ
$resourceGroup = "{{resource-group-name}}"
$sourceResourceId = "{{resource-id-of-source-disk}}"
$newSnapshotName = "{{snapshot-name}}"
$location = "{{snapshot-location}}"
### Create snapshot configuration
$snapshotConfig = New-AzSnapshotConfig
... [see more](remediation.md)
policy.yamlβ
Linked Framework Sectionsβ
Section | Sub Sections | Internal Rules | Policies | Flags |
---|---|---|---|---|
πΌ Cloudaware Framework β πΌ Waste Reduction | 10 |