Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (2024)

  • Article

Applies to: ✔️ Linux VMs ✔️ Flexible scale sets

The scope of this article is to validate the encryption status of a virtual machine by using different methods: the Azure portal, PowerShell, the Azure CLI, or the operating system of the virtual machine (VM).

You can validate the encryption status during or after the encryption, by either:

  • Checking the disks attached to a particular VM.
  • Querying the encryption settings on each disk, whether the disk is attached or unattached.

This scenario applies for Azure Disk Encryption dual-pass and single-pass extensions. Linux distributions are the only environment for this scenario.

Note

We're using variables throughout the article. Replace the values accordingly.

Portal

In the Azure portal, inside the Extensions section, select the Azure Disk Encryption extension in the list. The information for Status message indicates the current encryption status:

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (1)

In the list of extensions, you'll see the corresponding Azure Disk Encryption extension version. Version 0.x corresponds to Azure Disk Encryption dual pass, and version 1.x corresponds to Azure Disk Encryption single pass.

You can get more details by selecting the extension and then selecting View detailed status. The detailed status of the encryption process appears in JSON format.

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (2)

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (3)

Another way to validate the encryption status is by looking at the Disk settings section.

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (4)

Note

This status means the disks have encryption settings stamped, not that they were actually encrypted at the OS level.

By design, the disks are stamped first and encrypted later. If the encryption process fails, the disks may end up stamped but not encrypted.

To confirm if the disks are truly encrypted, you can double check the encryption of each disk at the OS level.

PowerShell

You can validate the general encryption status of an encrypted VM by using the following PowerShell commands:

 $VMNAME="VMNAME" $RGNAME="RGNAME" Get-AzVmDiskEncryptionStatus -ResourceGroupName ${RGNAME} -VMName ${VMNAME}

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (5)

You can capture the encryption settings from each disk by using the following PowerShell commands.

Single pass

In a single pass, the encryption settings are stamped on each of the disks (OS and data). You can capture the encryption settings for an OS disk in a single pass as follows:

$RGNAME = "RGNAME"$VMNAME = "VMNAME"$VM = Get-AzVM -Name ${VMNAME} -ResourceGroupName ${RGNAME} $Sourcedisk = Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName $VM.StorageProfile.OsDisk.Name Write-Host "=============================================================================================================================================================" Write-Host "Encryption Settings:" Write-Host "=============================================================================================================================================================" Write-Host "Enabled:" $Sourcedisk.EncryptionSettingsCollection.Enabled Write-Host "Version:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettingsVersion Write-Host "Source Vault:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SourceVault.Id Write-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SecretUrl Write-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl Write-Host "============================================================================================================================================================="

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (6)

If the disk doesn't have encryption settings stamped, the output will be empty:

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (7)

Use the following commands to capture encryption settings for data disks:

$RGNAME = "RGNAME"$VMNAME = "VMNAME"$VM = Get-AzVM -Name ${VMNAME} -ResourceGroupName ${RGNAME} clear foreach ($i in $VM.StorageProfile.DataDisks|ForEach-Object{$_.Name}) { Write-Host "=============================================================================================================================================================" Write-Host "Encryption Settings:" Write-Host "=============================================================================================================================================================" Write-Host "Checking Disk:" $i $Disk=(Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName $i) Write-Host "Encryption Enable: " $Sourcedisk.EncryptionSettingsCollection.Enabled Write-Host "Encryption KeyEncryptionKey: " $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrl; Write-Host "Encryption DiskEncryptionKey: " $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SecretUrl; Write-Host "=============================================================================================================================================================" }

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (8)

Dual pass

In a dual pass, the encryption settings are stamped in the VM model and not on each individual disk.

To verify that the encryption settings were stamped in a dual pass, use the following commands:

$RGNAME = "RGNAME"$VMNAME = "VMNAME"$vm = Get-AzVm -ResourceGroupName ${RGNAME} -Name ${VMNAME};$Sourcedisk = Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName $VM.StorageProfile.OsDisk.NameclearWrite-Host "============================================================================================================================================================="Write-Host "Encryption Settings:"Write-Host "============================================================================================================================================================="Write-Host "Enabled:" $Sourcedisk.EncryptionSettingsCollection.EnabledWrite-Host "Version:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettingsVersionWrite-Host "Source Vault:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SourceVault.IdWrite-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SecretUrlWrite-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrlWrite-Host "============================================================================================================================================================="

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (9)

Unattached disks

Check the encryption settings for disks that aren't attached to a VM.

Managed disks

$Sourcedisk = Get-AzDisk -ResourceGroupName ${RGNAME} -DiskName ${TARGETDISKNAME}Write-Host "============================================================================================================================================================="Write-Host "Encryption Settings:"Write-Host "============================================================================================================================================================="Write-Host "Enabled:" $Sourcedisk.EncryptionSettingsCollection.EnabledWrite-Host "Version:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettingsVersionWrite-Host "Source Vault:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SourceVault.IdWrite-Host "Secret URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.DiskEncryptionKey.SecretUrlWrite-Host "Key URL:" $Sourcedisk.EncryptionSettingsCollection.EncryptionSettings.KeyEncryptionKey.KeyUrlWrite-Host "============================================================================================================================================================="

Azure CLI

You can validate the general encryption status of an encrypted VM by using the following Azure CLI commands:

VMNAME="VMNAME"RGNAME="RGNAME"az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (10)

Single pass

You can validate the encryption settings for each disk by using the following Azure CLI commands:

az vm encryption show -g ${RGNAME} -n ${VMNAME} --query "disks[*].[name, statuses[*].displayStatus]" -o table

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (11)

Important

If the disk doesn't have encryption settings stamped, you'll see the text Disk is not encrypted.

Use the following commands to get detailed status and encryption settings.

OS disk:

RGNAME="RGNAME"VMNAME="VNAME"disk=`az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.osDisk.name -o tsv`for disk in $disk; do \echo "============================================================================================================================================================="echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \echo "============================================================================================================================================================="done

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (12)

Data disks:

RGNAME="RGNAME"VMNAME="VMNAME"az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} --query "substatus"for disk in `az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.dataDisks[].name -o tsv`; do \echo "============================================================================================================================================================="; \echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \echo "============================================================================================================================================================="done

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (13)

Dual pass

az vm encryption show --name ${VMNAME} --resource-group ${RGNAME} -o table

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (14)

You can also check the encryption settings on the VM Model Storage profile of the OS disk:

disk=`az vm show -g ${RGNAME} -n ${VMNAME} --query storageProfile.osDisk.name -o tsv`for disk in $disk; do \echo "============================================================================================================================================================="; \echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${disk} --query name -o tsv; \echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.enabled -o tsv; \echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${disk} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \echo "============================================================================================================================================================="done

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (15)

Unattached disks

Check the encryption settings for disks that aren't attached to a VM.

Managed disks

RGNAME="RGNAME"TARGETDISKNAME="DISKNAME"echo "============================================================================================================================================================="echo -ne "Disk Name: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query name -o tsv; \echo -ne "Encryption Enabled: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.enabled -o tsv; \echo -ne "Version: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettingsVersion -o tsv; \echo -ne "Disk Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettings[].diskEncryptionKey.secretUrl -o tsv; \echo -ne "key Encryption Key: "; az disk show -g ${RGNAME} -n ${TARGETDISKNAME} --query encryptionSettingsCollection.encryptionSettings[].keyEncryptionKey.keyUrl -o tsv; \echo "============================================================================================================================================================="

Unmanaged disks

Unmanaged disks are VHD files that are stored as page blobs in Azure storage accounts.

To get the details for a specific disk, you need to provide:

  • The ID of the storage account that contains the disk.
  • A connection string for that particular storage account.
  • The name of the container that stores the disk.
  • The disk name.

This command lists all the IDs for all your storage accounts:

az storage account list --query [].[id] -o tsv

The storage account IDs are listed in the following form:

/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>

Select the appropriate ID and store it on a variable:

id="/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>"

This command gets the connection string for one particular storage account and stores it on a variable:

ConnectionString=$(az storage account show-connection-string --ids $id --query connectionString -o tsv)

The following command lists all the containers under a storage account:

az storage container list --connection-string $ConnectionString --query [].[name] -o tsv

The container used for disks is normally named "vhds."

Store the container name on a variable:

ContainerName="name of the container"

Use this command to list all the blobs on a particular container:

az storage blob list -c ${ContainerName} --connection-string $ConnectionString --query [].[name] -o tsv

Choose the disk that you want to query and store its name on a variable:

DiskName="diskname.vhd"

Query the disk encryption settings:

az storage blob show -c ${ContainerName} --connection-string ${ConnectionString} -n ${DiskName} --query metadata.DiskEncryptionSettings

Operating system

Validate if the data disk partitions are encrypted (and the OS disk isn't).

When a partition or disk is encrypted, it's displayed as a crypt type. When it's not encrypted, it's displayed as a part/disk type.

sudo lsblk

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (16)

You can get more details by using the following lsblk variant.

You'll see a crypt type layer that is mounted by the extension. The following example shows logical volumes and normal disks having crypto_LUKS FSTYPE.

sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,RO,MOUNTPOINT

Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (17)

As an extra step, you can validate if the data disk has any keys loaded:

sudo cryptsetup luksDump /dev/VGNAME/LVNAME
sudo cryptsetup luksDump /dev/sdd1

And you can check which dm devices are listed as crypt:

sudo dmsetup ls --target crypt

Next steps

  • Azure Disk Encryption troubleshooting
Verify encryption status for Linux - Azure Disk Encryption - Azure Virtual Machines (2024)
Top Articles
Do You Have Too Many Stocks In Your Portfolio? How to Tell
How To Buy Amazon Stock (AMZN)
Minooka Channahon Patch
123Movies Encanto
The Atlanta Constitution from Atlanta, Georgia
Ingles Weekly Ad Lilburn Ga
Northern Whooping Crane Festival highlights conservation and collaboration in Fort Smith, N.W.T. | CBC News
Unlocking the Enigmatic Tonicamille: A Journey from Small Town to Social Media Stardom
Morocco Forum Tripadvisor
Wgu Admissions Login
Craigslist Deming
Craigslist Malone New York
The ULTIMATE 2023 Sedona Vortex Guide
Idaho Harvest Statistics
Dignity Nfuse
Q Management Inc
Video shows two planes collide while taxiing at airport | CNN
How to Create Your Very Own Crossword Puzzle
Account Suspended
Heart and Vascular Clinic in Monticello - North Memorial Health
U Of Arizona Phonebook
R&S Auto Lockridge Iowa
Does Hunter Schafer Have A Dick
Mineral Wells Skyward
Craigslist Dubuque Iowa Pets
Cardaras Funeral Homes
Gma' Deals & Steals Today
Vivification Harry Potter
Craigslist Scottsdale Arizona Cars
100 Million Naira In Dollars
Wells Fargo Bank Florida Locations
Halsted Bus Tracker
Pfcu Chestnut Street
Solarmovie Ma
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
Gets Less Antsy Crossword Clue
Smith And Wesson Nra Instructor Discount
Main Street Station Coshocton Menu
Trizzle Aarp
sacramento for sale by owner "boats" - craigslist
Scarlet Maiden F95Zone
Inducement Small Bribe
Ladyva Is She Married
6576771660
Embry Riddle Prescott Academic Calendar
Hampton In And Suites Near Me
Backpage New York | massage in New York, New York
St Als Elm Clinic
28 Mm Zwart Spaanplaat Gemelamineerd (U999 ST9 Matte | RAL9005) Op Maat | Zagen Op Mm + ABS Kantenband
Adams County 911 Live Incident
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 5653

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.