Skip to content

Commit 85ae091

Browse files
committed
add code block syntax
1 parent 0014446 commit 85ae091

File tree

1 file changed

+62
-33
lines changed

1 file changed

+62
-33
lines changed

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

Lines changed: 62 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
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.
2+
title: Manual backup and recovery of guest state protection keys for Trusted launch Azure Local VMs enabled by Azure Arc
3+
description: Learn how to perform a manual backup and recovery of guest state protection keys for Trusted launch Azure Local VMs enabled by Azure Arc.
44
author: alkohli
55
ms.author: alkohli
66
ms.topic: how-to
@@ -9,23 +9,25 @@ ms.reviewer: alkohli
99
ms.date: 07/21/2025
1010
---
1111

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

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

16-
This article describes how to manually back up and restore a Trusted launch for Azure Local VM enabled by Azure Arc.
16+
This article describes how to manually back up and restore guest state protection keys for Trusted launch Azure Local virtual machines (VMs) enabled by Azure Arc.
1717

18-
- **For 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**: Back up and restore Azure Local VM guest state protection keys to and from a file system folder.
1919

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.
20+
- **For Azure Local releases prior to 2505**: Back up and restore Azure Local VM guest state protection keys to and from a key vault in another Azure Local instance.
2121

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

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.
24+
This section applies to Azure local release 2505 and later.
2525

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.
26+
For back up, VM guest state protection keys are copied 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.
2727

28-
### Backup
28+
For restore, VM guest state protection keys are restored from a folder containing the backup copy to the key vault of an Azure Local instance where the VMs need to be restored.
29+
30+
### Back up
2931

3032
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.
3133

@@ -85,16 +87,17 @@ The steps below involve restoring VM guest state protection keys from a folder c
8587
Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName> -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize 2048
8688
```
8789
88-
1. Delete `AzureStackTvmAKRootKey` as follows:
90+
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:
8991
90-
> [!NOTE]
91-
> Do this step only if you're restoring the VM to the same Azure Local instance (the Azure Local instance where the VM resided before failure).
92-
93-
`Remove-MocKey -name  AzureStackTvmAKRootKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
92+
```powershell
93+
Remove-MocKey -name  AzureStackTvmAKRootKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault
94+
```
9495
9596
1. Restore the keys from backup:
9697
97-
`Import-TVMKeys -WrappingKeyName <WrappingKeyName> -BackupPath <path to timestamped backup folder>`
98+
```powershell
99+
Import-TVMKeys -WrappingKeyName <WrappingKeyName> -BackupPath <path to timestamped backup folder>
100+
```
98101
99102
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.
100103
@@ -103,54 +106,70 @@ The steps below involve restoring VM guest state protection keys from a folder c
103106
1. Delete both `public.pem` and `private.pem` files from the Azure Local instance.
104107
105108
> [!IMPORTANT]
106-
> Remove the wrapping key from the local key vault of the Azure Local instance using `Remove-MocKey`. This will help avoid collisions later.
109+
> Remove the wrapping key from the key vault of the Azure Local instance using `Remove-MocKey`. This will help avoid collisions later.
107110
108-
1. Run `Remove-MocKey -name WrappingKeyName -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
111+
```powershell
112+
Remove-MocKey -name WrappingKeyName -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault
113+
```
109114
110115
111116
# [Azure Local releases prior to 2505](#tab/azure-local-releases-prior-to-2505)
112117
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.
118+
This section applies to Azure Local releases prior to 2505.
119+
120+
For back up, the VM guest state protection keys are copied from the on-premises key vault of your Azure Local instance to the key vault of another Azure Local instance that is used for key back up purposes.
114121
115-
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.
122+
For restore, the VM guest state protection keys are restored from the local backup key vault of the Azure Local instance to the key vault of an Azure Local instance where the VMs need to be restored.
116123
117124
### Back up
118125
119126
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:
120127
121128
1. On the Azure Local system with the backup key vault, run the following commands on the Azure Local system with the backup key vault:
122129
123-
1. Create a wrapping key in the backup key vault:
130+
1. Create a wrapping key in the backup key vault. Make note of the name as you'll need it later:
124131
125-
`New-MocKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type RSA -size 2048`
132+
```powershell
133+
New-MocKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type RSA -size 2048
134+
```
126135
127136
1. Download the Privacy Enhanced Mail (PEM) file:
128137
129-
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem`
138+
```powershell
139+
Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem
140+
```
130141
131142
1. On the Azure Local system where the VM resides, run the following commands on the Azure Local system:
132143
133144
1. Copy the PEM file to the Azure Local system.
134145
135146
1. Confirm the owner node of the VM by running:
136147
137-
`Get-ClusterGroup <VM name>`
148+
```powershell
149+
Get-ClusterGroup <VM name>
150+
```
138151
139152
1. Run the following cmdlet on the owner node to determine the VM ID:
140153
141-
`(Get-VM -Name <VM name>).vmid`
154+
```powershell
155+
(Get-VM -Name <VM name>).vmid
156+
```
142157
143158
1. Export the VM guest state protection key:
144159
145-
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`
160+
```powershell
161+
Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256
162+
```
146163
147164
1. On the Azure Local system with the backup key vault, run the following steps:
148165
149166
1. Copy the `VM ID` and `VM ID`.json file to the Azure Local system.
150167
151168
1. Import the VM guest state protection key to the backup key vault:
152169
153-
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`
170+
```powershell
171+
Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256
172+
```
154173
155174
### Restore
156175
@@ -160,36 +179,46 @@ Follow these steps to copy the VM guest state protection key. The key is copied
160179
161180
1. Create a wrapping key in the key vault:
162181
163-
`New-MocKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type RSA -size 2048`
182+
```powershell
183+
New-MocKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type RSA -size 2048
184+
```
164185
165186
1. Download the PEM file:
166187
167-
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem`
188+
```powershell
189+
Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem
190+
```
168191
169192
1. On the Azure Local system with the backup key vault, run the following commands:
170193
171194
1. Copy the PEM file to the Azure Local system.
172195
173196
1. Get the `VM ID` from the VM files stored on disk. There will be a VM config file (.xml) that has the `VM ID` as its name. You can also use the following command to obtain the `VM ID` if you know the VM name. Perform this step on a Hyper-V host that has the VM files:
174197
175-
`(Get-VM -Name <VM name>).vmid`
198+
```powershell
199+
(Get-VM -Name <VM name>).vmid
200+
```
176201
177202
1. Export the VM guest state protection key:
178203
179-
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`
204+
```powershell
205+
Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256
206+
```
180207
181208
1. On the Azure Local system where the VM needs to be restored, run the following commands from the target Azure Local system:
182209
183210
1. Copy the `VM ID` and `VM ID`.json file to the Azure Local system.
184211
185212
1. Import the VM guest state protection key:
186213
187-
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`
188-
189214
> [!NOTE]
190215
> 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.
191216
192-
`Remove-MocKey -name <vm id> -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
217+
```powershell
218+
Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256
219+
220+
Remove-MocKey -name <vm id> -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault
221+
```
193222
194223
---
195224

0 commit comments

Comments
 (0)