Skip to content

Commit c99b821

Browse files
committed
updated per new Word doc changes
1 parent 53cb306 commit c99b821

File tree

2 files changed

+60
-60
lines changed

2 files changed

+60
-60
lines changed

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

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,115 +6,115 @@ ms.author: alkohli
66
ms.topic: how-to
77
ms.service: azure-local
88
ms.reviewer: alkohli
9-
ms.date: 07/10/2025
9+
ms.date: 07/14/2025
1010
---
1111

1212
# Manual backup and recovery of VM guest state protection key
1313

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

16-
You can backup and restore the VM guest state protection key of each Trusted launch VM on an Azure Local instance using one of the following approaches.
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.
1717

18-
**Approach 1** (recommended): Backup/restore VM guest state protection keys to/from a file system folder. You can use this approach starting with Azure Local 2505 release and onwards. If your Azure Local instance uses an earlier Azure Local release, you can instead use approach 2.
18+
- **Azure Local release 2505 and later**: Backup/restore VM guest state protection keys to/from a file system folder.
1919

20-
**Approach 2**: Backup/restore VM guest state protection keys to/from a key vault in another Azure Local instance. Use this approach only if your Azure Local instance uses an earlier Azure Local release earlier than 2505.
20+
- **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-
## Backup and restore VM guest state protection keys using file system folder
22+
## For 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.
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.
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+
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.
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
> [!NOTE]
33-
> You can only use this approach starting with Azure Local 2505 release and onwards. If your Azure Local instance uses an earlier Azure Local release, you can instead use approach 2.
33+
> You can only use this method for Azure Local 2505 release and later. If your Azure Local instance uses an earlier Azure Local release, use the other method.
3434
35-
1. On a secure computer using PowerShell 7, generate a wrapping key:
35+
1. On a secure computer using PowerShell 7, generate a wrapping key of size 2048:
3636

3737
```azurepowershell
38-
$rsa = [System.Security.Cryptography.RSA]::Create(2048)
38+
$rsa = [System.Security.Cryptography.RSA]::Create(2048)
3939
4040
$privateKeyPem = $rsa.ExportPkcs8PrivateKeyPem()
4141
4242
$privateKeyPem | Out-File -FilePath .\private.pem
4343
4444
$publicKeyPem = $rsa.ExportRSAPublicKeyPem()
4545
46-
$publicKeyPem | Out-File -FilePath .\public.pem
46+
$publicKeyPem | Out-File -FilePath .\public.pem
4747
```
4848
4949
1. Copy the `.\public.pem` file to your Azure Local instance.
5050
5151
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:
5252
53-
1. Download `TvmBackupUtils.psm1` script file on GitHub repo `Azure-Samples/AzureLocal` to your Azure Local instance.
53+
1. Download the `TvmBackupUtils.psm1` script file located on GitHub (link to repo path) to your Azure Local instance.
5454
5555
1. Run `import-module .\TvmBackupUtils.psm1 -force`.
5656
57-
1. Run `Backup-TVMKeys -WrappingKeyPath <path to public.pem> -BackupRootPath` (path to backup root folder where the timestamped backup folder will be stored).
57+
1. Run `Backup-TVMKeys -WrappingKeyPath <path to public.pem> -BackupRootPath <path to backup root folder where the timestamped backup folder is stored>`.
5858
59-
1. Make note of the timestamped backup folder created under the backup root folder. You will need this later during recovery.
59+
1. Make note of the timestamped backup folder created under the backup root folder. You will need this later during recovery. For examople, backup folder named "20250612205355" with the format "yyyyMMddHHmmss".
6060
61-
1. Make sure to periodically backup the backup root folder.
61+
1. Periodically backup the backup root folder.
6262
6363
### Restore
6464
65-
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.
65+
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.
6666
67-
> [!NOTE]
68-
> You can only use this approach starting Azure Local 2505 release and onwards. If your Azure Local instance is on an earlier Azure Local release, you can instead use approach 2.
69-
70-
1. Copy both private and public key files for the wrapping key (which you had created during backup step 1) to the Azure Local instance.
67+
1. Copy both private and public key files for the wrapping key that you created during step 1 for Backup to the Azure Local instance.
7168
72-
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.
69+
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.
7370
7471
> [!NOTE]
7572
>Don't modify the backup folder.
7673
77-
1. Import the wrapping key (which you had created during backup step 1) to the Azure Local instance:
74+
1. Import the wrapping key that you created during backup step 1 for Backup to the Azure Local instance:
7875
79-
1. Download the `TvmBackupUtils.psm1` script file (link to file on GitHub repo Azure-Samples/AzureLocal: Contains scripts, code samples, for Azure Stack HCI) to your Azure Local instance.
76+
1. Download the `TvmBackupUtils.psm1` script file on Github at (link to file on GitHub repo Azure-Samples/AzureLocal: Contains scripts, code samples, for Azure Stack HCI) to your Azure Local instance.
8077
8178
1. Run `Import-Module .\TvmBackupUtils.psm1 -force`.
8279
8380
> [!NOTE]
84-
> Make sure the WrappingKeyName you specify does not match the name of a key already existing in the backup (timestamped backup folder). Otherwise, this will cause a failure during import (restore step 4).
81+
> 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).
8582
86-
1. Run `Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName>  -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize <size of key generated 2048>`
83+
1. Run `Import-TvmWrappingKeyFromPem -KeyName <WrappingKeyName>  -PublicKeyPath <path to public.pem> -PrivateKeyPath <path to private.pem> -KeySize 2048`
84+
85+
1. Delete `AzureStackTvmAKRootKey`:
86+
87+
> [!NOTE]
88+
> 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).
89+
90+
`Remove-MocKey -name  AzureStackTvmAKRootKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`
8791
8892
1. Restore the keys from backup:
8993
90-
`Import-TVMKeys -WrappingKeyName  <WrappingKeyName> -BackupPath <path to timestamped backup folder>`.
94+
`Import-TVMKeys -WrappingKeyName  <WrappingKeyName> -BackupPath <path to timestamped backup folder> `.
9195
9296
> [NOTE!]
93-
> If the local key vault of the Azure Local instance already has a VM guest state protection key with the same name, you will receive an InvalidVersion error for that key. You can ignore this, as the key is already in the key vault.
97+
> 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.
9498
95-
1. Cleanup files and keys
99+
1. Cleanup files and keys:
96100
97-
1. Delete both public.pem and private.pem files from the Azure Local instance.
101+
1. Delete both `public.pem` and `private.pem` files from the Azure Local instance.
98102
99103
> [!IMPORTANT]
100-
> Remove the wrapping key from the local key vault of the Azure Local instance using Remove-MocKey. This will help avoid collisions later.
104+
> Remove the wrapping key from the local key vault of the Azure Local instance using `Remove-MocKey`. This will help avoid collisions later.
101105
102106
1. Run `Remove-MocKey -name WrappingKeyName -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`.
103107
104-
> [!NOTE]
105-
> You should start a VM on the Azure Local instance only after you have successfully restored both its VM files and its VM guest state protection key. If you had inadvertently attempted to start a VM before restoring its VM guest state protection key, you must delete the AzureStackTvmAKRootKey (which would have been auto generated) from the local key vault of the Azure Local instance.
106-
107-
1. Run `Remove-MocKey -name  AzureStackTvmAKRootKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`.
108108
109-
## Backup or restore VM guest state protection keys via a key vault in another Azure Local instance
109+
## For Azure Local releases prior to 2505
110110
111-
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 (backup key vault) of another Azure Local instance (which is used for key backup purposes).
111+
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.
112112
113-
To restore, this approach restores VM guest state protection keys from the local key vault (backup key vault) of the Azure Local instance (which is used for key backup purposes) to the local key vault of an Azure Local instance where the VMs need to be restored.
113+
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.
114114
115115
### Backup
116116
117-
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:
117+
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:
118118
119119
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:
120120
@@ -124,55 +124,55 @@ Follow these steps to copy the VM guest state protection key from the local key
124124
125125
1. Download the Privacy Enhanced Mail (PEM) file:
126126
127-
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem`
127+
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem `
128128
129129
1. On the Azure Local system where the VM resides, run the following commands on the Azure Local system:
130130
131131
1. Copy the PEM file to the Azure Local system.
132132
133-
1. Confirm the owner node of the VM:
133+
1. Confirm the owner node of the VM by running:
134134
135135
`Get-ClusterGroup <VM name>`
136136
137137
1. Run the following cmdlet on the owner node to determine the VM ID:
138138
139-
1. `(Get-VM -Name <VM name>).vmid`
139+
`(Get-VM -Name <VM name>).vmid`
140140
141-
1. Export the VM guest state protection key:
141+
1. Export the VM guest state protection key:
142142
143-
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`
143+
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`
144144
145145
1. On the Azure Local system with the backup key vault, run the following steps on the Azure Local system:
146146
147147
1. Copy the `VM ID` and `VM ID`.json file to the Azure Local system.
148148
149149
1. Import the VM guest state protection key to the backup key vault:
150150
151-
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`.
151+
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`.
152152
153153
### Restore
154154
155-
Follow these steps to copy the VM guest state protection key from the backup key vault of the Azure Local instance (which was used for key backup purposes) to the local key vault of the target Azure Local system (where the VM needs to be restored):
155+
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:
156156
157157
1. On the source Azure Local system where the VM needs to be restored, run the following commands on the Azure Local system:
158158
159159
1. Create a wrapping key in the key vault:
160160
161161
`New-MocKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type RSA -size 2048`
162162
163-
1. Download the Privacy Enhanced Mail (PEM) file:
163+
1. Download the PEM file:
164164
165165
`Get-MocKeyPublicKey -name wrappingKey -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -outputFile wrappingKey.pem`
166166
167-
1. On the Azure Local system with the backup key vault, run the following commands on the Azure Local system.
167+
1. On the Azure Local system with the backup key vault, run the following commands on the Azure Local system.
168168
169-
1. Copy the PEM file to the Azure Local system.
169+
1. Copy the PEM file to the Azure Local system.
170170
171-
1. Get the `VM ID` from the VM files stored on disk (wherever this is located). 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. You need to do this step on a Hyper-V host that has the VM files.
171+
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:
172172
173173
`(Get-VM -Name <VM name>).vmid`
174174
175-
1. Export the VM guest state protection key.
175+
1. Export the VM guest state protection key:
176176
177177
`Export-MocKey -name <VM ID> -wrappingKeyName wrappingKey -wrappingPubKeyFile wrappingKey.pem -outFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -size 256`.
178178
@@ -185,7 +185,7 @@ Follow these steps to copy the VM guest state protection key from the backup key
185185
`Import-MocKey -name <VM ID> -importKeyFile <VM ID>.json -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault -type AES -size 256`.
186186
187187
> [!NOTE]
188-
> 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.
188+
> 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.
189189
190190
`Remove-MocKey -name <vm id> -group AzureStackHostAttestation -keyvaultName AzureStackTvmKeyVault`.
191191

0 commit comments

Comments
 (0)