Skip to content

Commit 0014446

Browse files
committed
add Alpa feedback
1 parent 8f7368f commit 0014446

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed

azure-local/manage/trusted-launch-vm-import-key.md

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
---
2-
title: Manual backup and recovery of VM guest state protection key
3-
description: Learn how to perform a manual backup and recovery of a VM guest state protection key.
2+
title: Manual backup and recovery of guest state protection key for Trusted launch Azure Local VMs
3+
description: Learn how to perform a manual backup and recovery of guest state protection key for Trusted launch Azure Local VMs.
44
author: alkohli
55
ms.author: alkohli
66
ms.topic: how-to
77
ms.service: azure-local
88
ms.reviewer: alkohli
9-
ms.date: 07/15/2025
9+
ms.date: 07/21/2025
1010
---
1111

12-
# Manual backup and recovery of VM guest state protection key
12+
# Manual backup and recovery of guest state protection key for Trusted launch Azure Local VMs
1313

1414
[!INCLUDE [applies-to](../includes/hci-applies-to-23h2.md)]
1515

16-
You can backup and restore the virtual machine (VM) guest state protection key of each Trusted launch VM on an Azure Local instance using one of the following methods.
16+
This article describes how to manually back up and restore a Trusted launch for Azure Local VM enabled by Azure Arc.
1717

18-
- **Azure Local release 2505 and later**: Backup/restore VM guest state protection keys to/from a file system folder.
18+
- **For Azure Local release 2505 and later**: Backup/restore VM guest state protection keys to/from a file system folder.
1919

20-
- **Azure Local releases prior to 2505**: Backup/restore VM guest state protection keys to/from a key vault in another Azure Local instance.
20+
- **For Azure Local releases prior to 2505**: Backup/restore VM guest state protection keys to/from a key vault in another Azure Local instance.
2121

22-
## For Azure Local release 2505 and later
22+
# [Azure Local release 2505 and later](#tab/azure-local-release-2505-and-later)
2323

24-
To backup, this approach copies VM guest state protection keys from the local key vault of your Azure Local instance to a folder that is backed up periodically. The VM guest state protection keys stored inside that folder are in an encrypted form.
24+
For back up, this method copies VM guest state protection keys from the on-premises key vault of your Azure Local instance to a folder that is backed up periodically. The VM guest state protection keys stored inside that folder are in an encrypted form.
2525

26-
To restore, this approach restores VM guest state protection keys from a folder (containing the backup copy) to the local key vault of an Azure Local instance where the VMs need to be restored.
26+
For restore, this method restores VM guest state protection keys from a folder (containing the backup copy) to the local key vault of an Azure Local instance where the VMs need to be restored.
2727

2828
### Backup
2929

3030
The steps below involve copying VM guest state protection keys from the local key vault of your Azure Local instance to a folder that is backed up periodically.
3131

3232
1. On a secure computer using PowerShell 7, generate a wrapping key of size 2048:
3333

34-
```azurepowershell
34+
```powershell
3535
$rsa = [System.Security.Cryptography.RSA]::Create(2048)
3636
3737
$privateKeyPem = $rsa.ExportPkcs8PrivateKeyPem()
@@ -42,42 +42,48 @@ The steps below involve copying VM guest state protection keys from the local ke
4242
4343
$publicKeyPem | Out-File -FilePath .\public.pem
4444
```
45+
1. Make a note of the wrapping key as you'll need it later.
4546
4647
1. Copy the `.\public.pem` file to your Azure Local instance.
4748
4849
1. Copy VM guest state protection keys from the local key vault of your Azure Local instance to a folder that is backed up periodically:
4950
5051
1. Download the [TvmBackupUtils.psm1 script](https://github.com/Azure-Samples/AzureLocal/blob/main/trusted-launch-vms/TvmBackupUtils.psm1) on GitHub to your Azure Local instance.
5152
52-
1. Run `import-module .\TvmBackupUtils.psm1 -force`.
53+
1. Run the following:
5354
54-
1. Run `Backup-TVMKeys -WrappingKeyPath <path to public.pem> -BackupRootPath <path to backup root folder where the timestamped backup folder is stored>`.
55+
```powershell
56+
import-module .\TvmBackupUtils.psm1 -force
57+
58+
Backup-TVMKeys -WrappingKeyPath <path to public.pem> -BackupRootPath <path to backup root folder where the timestamped backup folder is stored>
59+
```
5560
5661
1. Make note of the timestamped backup folder created under the backup root folder. You will need this later during recovery. For example, backup folder named "20250612205355" with the format "yyyyMMddHHmmss".
5762
58-
1. Periodically backup the backup root folder.
63+
1. Any time you create a new VM on Azure Local instance, run the script and back up the keys in the key vault.
5964
6065
### Restore
6166
62-
The steps below involve restoring VM guest state protection keys from a folder containing the backup copy to the local key vault of an Azure Local instance where the VMs need to be restored.
67+
The steps below involve restoring VM guest state protection keys from a folder containing the backup copy to the key vault of an Azure Local instance where the VMs need to be restored.
6368
64-
1. Copy both private and public key files for the wrapping key that you created during Backup step 1 to the Azure Local instance.
69+
1. Copy both private and public key files for the wrapping key that you created previously to the Azure Local instance.
6570
6671
1. Copy the timestamped backup folder to the Azure Local instance. Pick the folder under the backup root folder with the latest timestamp as that folder will have the most recent copy.
6772
6873
> [!NOTE]
6974
> Don't modify the backup folder.
7075
71-
1. Import the wrapping key that you created during Backup step 1 to the Azure Local instance:
76+
1. Import the wrapping key that you created previously to the Azure Local instance:
7277
7378
1. Download the [TvmBackupUtils.psm1 script](https://github.com/Azure-Samples/AzureLocal/blob/main/trusted-launch-vms/TvmBackupUtils.psm1) on GitHub to your Azure Local instance.
7479
75-
1. Run `Import-Module .\TvmBackupUtils.psm1 -force`.
80+
1. Run the following commands. Make sure to create a unique name for the WrappingKeyName. Otherwise, this will cause a failure during import:
7681
77-
> [!NOTE]
78-
> Make sure the WrappingKeyName you specify doesn't match the name of a key already existing in the timestamped backup folder. Otherwise, this will cause a failure during import (see Restore step 5).
82+
```powershell
83+
Import-Module .\TvmBackupUtils.psm1 -force
7984
80-
1. Run `Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName> -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize 2048`
85+
Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName> -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize 2048
86+
```
8187
8288
1. Delete `AzureStackTvmAKRootKey` as follows:
8389
@@ -90,10 +96,9 @@ The steps below involve restoring VM guest state protection keys from a folder c
9096
9197
`Import-TVMKeys -WrappingKeyName <WrappingKeyName> -BackupPath <path to timestamped backup folder>`
9298
93-
> [!NOTE]
94-
> If the local key vault of the Azure Local instance already has a VM guest state protection key with the same name or already has an `AzureStackTvmAKRootKey`, you will receive an `InvalidVersion` error for that key. You can ignore this, as the key is already in the key vault.
99+
If the local key vault of the Azure Local instance already has a VM guest state protection key with the same name or already has an `AzureStackTvmAKRootKey`, you will receive an `InvalidVersion` error for that key. You can ignore this, as the key is already in the key vault.
95100
96-
1. Cleanup files and keys:
101+
1. Clean up files and keys:
97102
98103
1. Delete both `public.pem` and `private.pem` files from the Azure Local instance.
99104
@@ -103,13 +108,13 @@ The steps below involve restoring VM guest state protection keys from a folder c
103108
1. Run `Remove-MocKey -name WrappingKeyName -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
104109
105110
106-
## For Azure Local releases prior to 2505
111+
# [Azure Local releases prior to 2505](#tab/azure-local-releases-prior-to-2505)
107112
108-
To backup, this approach copies VM guest state protection keys from the local key vault of your Azure Local instance to the local key vault of another Azure Local instance that is used for key backup purposes.
113+
To back up, this method copies VM guest state protection keys from the local key vault of your Azure Local instance to the local key vault of another Azure Local instance that is used for key backup purposes.
109114
110115
To restore, this method restores VM guest state protection keys from the local key vault (backup key vault) of the Azure Local instance that is used for key backup purposes to the local key vault of an Azure Local instance where the VMs need to be restored.
111116
112-
### Backup
117+
### Back up
113118
114119
Follow these steps to copy the VM guest state protection key from the local key vault of the Azure Local instance where the VM resides to a backup key vault on another Azure Local instance:
115120
@@ -139,7 +144,7 @@ Follow these steps to copy the VM guest state protection key from the local key
139144
140145
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`
141146
142-
1. On the Azure Local system with the backup key vault, run the following steps on the Azure Local system:
147+
1. On the Azure Local system with the backup key vault, run the following steps:
143148
144149
1. Copy the `VM ID` and `VM ID`.json file to the Azure Local system.
145150
@@ -149,9 +154,9 @@ Follow these steps to copy the VM guest state protection key from the local key
149154
150155
### Restore
151156
152-
Follow these steps to copy the VM guest state protection key from the backup key vault of the Azure Local instance that is used for key backup purposes to the local key vault of the target Azure Local system where the VM needs to be restored:
157+
Follow these steps to copy the VM guest state protection key. The key is copied from the backup key vault of the Azure Local instance to the key vault of the target Azure Local system (where the VM needs to be restored):
153158
154-
1. On the source Azure Local system where the VM needs to be restored, run the following commands on the Azure Local system:
159+
1. On the source Azure Local system where the VM needs to be restored, run the following commands:
155160
156161
1. Create a wrapping key in the key vault:
157162
@@ -161,7 +166,7 @@ Follow these steps to copy the VM guest state protection key from the backup key
161166
162167
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem`
163168
164-
1. On the Azure Local system with the backup key vault, run the following commands on the Azure Local system.
169+
1. On the Azure Local system with the backup key vault, run the following commands:
165170
166171
1. Copy the PEM file to the Azure Local system.
167172
@@ -182,10 +187,12 @@ Follow these steps to copy the VM guest state protection key from the backup key
182187
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`
183188
184189
> [!NOTE]
185-
> Restore the VM guest state key (complete the steps above) before you start the VM on the Azure Local instance where the VM needs to be restored. This ensures that the VM uses the restored VM GSP key. Otherwise, the VM creation fails, and a new VM GSP key is created by the system. If this happens by mistake (human error), delete the VM GSP key and then repeat the steps to restore the VM GSP key.
190+
> Restore the VM guest state key (complete the steps above) before you start the VM on the Azure Local instance where the VM needs to be restored. This ensures that the VM uses the restored VM guest state protection key. Otherwise, the VM creation fails, and a new VM guest state protection key is created by the system. If this happens by mistake (human error), delete the VM guest state protection key and then repeat the steps to restore the VM guest state protection key key.
186191
187192
`Remove-MocKey -name <vm id> -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
188193
194+
---
195+
189196
## Next steps
190197
191198
- [Manage VM extensions](virtual-machine-manage-extension.md).

0 commit comments

Comments
 (0)