You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: azure-local/manage/trusted-launch-vm-import-key.md
+75-11Lines changed: 75 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ ms.author: alkohli
6
6
ms.topic: how-to
7
7
ms.service: azure-local
8
8
ms.reviewer: alkohli
9
-
ms.date: 07/21/2025
9
+
ms.date: 07/23/2025
10
10
---
11
11
12
12
# Manual backup and recovery of guest state protection keys for Trusted launch Azure Local VMs enabled by Azure Arc
@@ -59,34 +59,48 @@ The steps below involve copying VM guest state protection keys from the local ke
59
59
60
60
Backup-TVMKeys -WrappingKeyPath <path to public.pem> -BackupRootPath <path to backup root folder where the timestamped backup folder is stored>
61
61
```
62
+
Here is a sample output after running this command:
62
63
63
-
1. Make note of the timestamped backup folder created under the backup root folder. You'll need this later during recovery. For example, backup folder named "20250612205355" with the format "yyyyMMddHHmmss".
64
+
```output
65
+
Backing up TVM Vault keys to .\<backup root folder>\20250722192116
66
+
Backing up key 11111111-1111-1111-1111-111111111111 to AES folder
67
+
Backing up key 7fb16fe7-00a0-476f-92b3-ccb98fd9525a to AES folder
68
+
Backing up key AzureStackTvmAKRootKey to RSA folder
69
+
```
64
70
65
-
1. Anytime you create a new VM on Azure Local instance, run the script and back up the keys in the key vault.
71
+
1. Make note of the timestamped backup folder created under the backup root folder. You'll need this later during recovery. For example, backup folder named "20250612205355" with the format "yyyyMMddHHmmss".
66
72
67
73
### Restore keys
68
74
69
75
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.
70
76
71
77
1. Copy both private and public key files for the wrapping key that you created previously to the Azure Local instance.
72
78
73
-
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.
74
-
75
-
> [!NOTE]
76
-
> Don't modify the backup folder.
79
+
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. Don't modify the backup folder.
77
80
78
81
1. Import the wrapping key that you created previously to the Azure Local instance:
79
82
80
83
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.
81
84
82
-
1. Run the following commands. Make sure to create a unique name for the WrappingKeyName. Otherwise, this will cause a failure during import:
85
+
1. Run the following commands.
86
+
87
+
> [!NOTE]
88
+
> Make sure to create a unique name for the WrappingKeyName. Otherwise, this will cause a failure during import:
83
89
84
90
```powershell
85
91
Import-Module .\TvmBackupUtils.psm1 -force
86
92
87
93
Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName> -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize 2048
88
94
```
89
-
95
+
Here is sample output:
96
+
97
+
```output
98
+
Generating import JSON for key <WrappingKeyName> at temporary location C:\Users\HCIDeploymentUser\AppData\Local\Temp\tmpD383.tmp...
99
+
Importing key <WrappingKeyName> into the vault...
100
+
Key <WrappingKeyName> successfully imported into the vault.
101
+
Temporary file C:\Users\HCIDeploymentUser\AppData\Local\Temp\tmpD383.tmp has been cleaned up.
102
+
```
103
+
90
104
1. Do this step only if you're restoring the VM to the same Azure Local instance where the VM resided before failure. Delete `AzureStackTvmAKRootKey` as follows:
91
105
92
106
```powershell
@@ -98,9 +112,57 @@ The steps below involve restoring VM guest state protection keys from a folder c
98
112
```powershell
99
113
Import-TVMKeys -WrappingKeyName <WrappingKeyName> -BackupPath <path to timestamped backup folder>
100
114
```
115
+
Here is sample output:
116
+
117
+
```output
118
+
Importing TVM keys from .\tvm_keys_backup_root\20250722192116\
119
+
120
+
Importing key 11111111-1111-1111-1111-111111111111 with size 256 from AES folder path = .\tvm_keys_backup_root\20250722192116\AES\11111111-1111-1111-1111-111111111111_256.json
121
+
122
+
Importing key 7fb16fe7-00a0-476f-92b3-ccb98fd9525a with size 256 from AES folder path = .\tvm_keys_backup_root\20250722192116\AES\7fb16fe7-00a0-476f-92b3-ccb98fd9525a_256.json
123
+
124
+
Importing key AzureStackTvmAKRootKey with size 4096 from RSA folder path = .\tvm_keys_backup_root\20250722192116\RSA\AzureStackTvmAKRootKey_4096.json
125
+
```
101
126
102
127
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'll receive an `InvalidVersion` error for that key. You can ignore this, as the key is already in the key vault.
103
128
129
+
Here is sample output showing this error:
130
+
131
+
```output
132
+
Importing TVM keys from .\tvm_keys_backup_root\20250722192116\
133
+
Importing key 11111111-1111-1111-1111-111111111111 with size 256 from AES folder path = .\tvm_keys_backup_root\20250722192116\AES\11111111-1111-1111-1111-111111111111_256.json
> Restore the VM guest state key (complete the preceding steps) 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.
0 commit comments