Skip to content

Commit 6dda05e

Browse files
authored
Merge pull request #185373 from carlrab/azurecli_virtualmachines
Update parent files for disk samples (from archive)
2 parents f4a2ded + eded2b1 commit 6dda05e

9 files changed

+482
-7
lines changed

articles/virtual-machines/TOC.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,17 +1374,21 @@
13741374
- name: CLI
13751375
items:
13761376
- name: Create managed disk from a VHD
1377-
href: /previous-versions/azure/virtual-machines/scripts/virtual-machines-cli-sample-create-managed-disk-from-vhd
1377+
href: ./scripts/create-managed-disk-from-vhd.md
13781378
- name: Create a managed disk from a snapshot
1379-
href: /previous-versions/azure/virtual-machines/scripts/virtual-machines-cli-sample-create-managed-disk-from-vhd
1379+
href: ./scripts/create-managed-disk-from-snapshot.md
13801380
- name: Copy a managed disk to the same or different subscription
1381-
href: https://github.com/Azure-Samples/azure-cli-samples/blob/master/virtual-machine/copy-managed-disks-to-same-or-different-subscription/copy-managed-disks-to-same-or-different-subscription.sh
1382-
- name: Copy a snapshot to the same or different subscription
1383-
href: /previous-versions/azure/virtual-machines/scripts/virtual-machines-cli-sample-copy-managed-disks-to-same-or-different-subscription
1381+
href: ./scripts/copy-managed-disks-to-same-or-different-subscription.md
13841382
- name: Export a snapshot as a VHD to a storage account
1385-
href: /previous-versions/azure/virtual-machines/scripts/virtual-machines-cli-sample-copy-snapshot-to-storage-account
1383+
href: ./scripts/copy-snapshot-to-storage-account.md
13861384
- name: Export a managed disk as a VHD to a storage account
1387-
href: /previous-versions/azure/virtual-machines/scripts/virtual-machines-cli-sample-copy-snapshot-to-storage-account
1385+
href: ./scripts/copy-managed-disks-vhd-to-storage-account.md
1386+
- name: Copy a snapshot to the same or different subscription
1387+
href: ./scripts/copy-snapshot-to-same-or-different-subscription.md
1388+
- name: Create virtual machine from snapshot
1389+
href: ./scripts/create-vm-from-snapshot.md
1390+
- name: Create virtual machine from existing managed OS disk
1391+
href: ./scripts/create-vm-from-managed-os-disks.md
13881392
- name: PowerShell
13891393
items:
13901394
- name: Create managed disk from a VHD
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: Copy managed disks to same or different subscription - CLI Sample
3+
description: Azure CLI Script Sample - Copy (or move) managed disks to the same or a different subscription
4+
documentationcenter: storage
5+
author: ramankumarlive
6+
manager: kavithag
7+
ms.service: virtual-machines
8+
ms.devlang: azurecli
9+
ms.topic: sample
10+
ms.workload: infrastructure
11+
ms.date: 02/23/2022
12+
ms.author: ramankum
13+
ms.custom: mvc
14+
---
15+
16+
# Copy managed disks to same or different subscription with CLI
17+
18+
This script copies a managed disk to same or different subscription but in the same region. The copy works only when the subscriptions are part of the same Azure AD tenant.
19+
20+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
21+
22+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
23+
24+
## Sample script
25+
26+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
27+
28+
### Run the script
29+
30+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-managed-disks-to-same-or-different-subscription/copy-managed-disks-to-same-or-different-subscription.sh" range="3-32":::
31+
32+
## Clean up resources
33+
34+
Run the following command to remove the resource group, VM, and all related resources.
35+
36+
```azurecli-interactive
37+
az group delete --name mySourceResourceGroupName
38+
```
39+
40+
## Sample reference
41+
42+
This script uses following commands to create a new managed disk in the target subscription using the `Id` of the source managed disk. Each command in the table links to command specific documentation.
43+
44+
| Command | Notes |
45+
|---|---|
46+
| [az disk show](/cli/azure/disk) | Gets all the properties of a managed disk using the name and resource group properties of the managed disk. The `Id` property is used to copy the managed disk to different subscription. |
47+
| [az disk create](/cli/azure/disk) | Copies a managed disk by creating a new managed disk in different subscription using the `Id` and name the parent managed disk. |
48+
49+
## Next steps
50+
51+
[Create a virtual machine from a managed disk](./virtual-machines-linux-cli-sample-create-vm-from-managed-os-disks.md?toc=%2fpowershell%2fmodule%2ftoc.json)
52+
53+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
54+
55+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Copy a managed disk to a storage account - CLI
3+
description: Azure CLI sample - Export or copy a managed disk to a storage account.
4+
documentationcenter: storage
5+
author: ramankumarlive
6+
manager: kavithag
7+
ms.service: virtual-machines
8+
ms.subservice: disks
9+
ms.topic: sample
10+
ms.workload: infrastructure
11+
ms.date: 02/23/2022
12+
ms.author: ramankum
13+
ms.custom: "mvc,seodec18, devx-track-azurecli"
14+
---
15+
16+
# Export/Copy a managed disk to a storage account using the Azure CLI
17+
18+
This script exports the underlying VHD of a managed disk to a storage account in same or different region. It first generates the SAS URI of the managed disk and then uses it to copy the VHD to a storage account. Use this script to copy managed disks to another region for regional expansion. If you want to publish the VHD file of a managed disk in Azure Marketplace, you can use this script to copy the VHD file to a storage account and then generate a SAS URI of the copied VHD to publish it in the Marketplace.
19+
20+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
21+
22+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
23+
24+
## Sample script
25+
26+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
27+
28+
### Run the script
29+
30+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-managed-disks-vhd-to-storage-account/copy-managed-disks-vhd-to-storage-account.sh" range="3-33":::
31+
32+
## Clean up resources
33+
34+
Run the following command to remove the resource group, VM, and all related resources.
35+
36+
```azurecli-interactive
37+
az group delete --name myResourceGroupName
38+
```
39+
40+
## Sample reference
41+
42+
This script uses following commands to generate the SAS URI for a managed disk and copies the underlying VHD to a storage account using the SAS URI. Each command in the table links to command specific documentation.
43+
44+
| Command | Notes |
45+
|---|---|
46+
| [az disk grant-access](/cli/azure/disk#az-disk-grant-access) | Generates read-only SAS that is used to copy the underlying VHD file to a storage account or download it to on-premises |
47+
| [az storage blob copy start](/cli/azure/storage/blob/copy) | Copies a blob asynchronously from one storage account to another |
48+
49+
## Next steps
50+
51+
[Create a managed disk from a VHD](virtual-machines-cli-sample-create-managed-disk-from-vhd.md)
52+
53+
[Create a virtual machine from a managed disk](virtual-machines-linux-cli-sample-create-vm-from-managed-os-disks.md)
54+
55+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
56+
57+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md).
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Copy managed disk snapshot to a subscription - CLI Sample
3+
description: Azure CLI Script Sample - Copy (or move) snapshot of a managed disk to same or different subscription with CLI
4+
documentationcenter: storage
5+
author: ramankumarlive
6+
manager: kavithag
7+
ms.service: virtual-machines
8+
ms.subservice: disks
9+
ms.topic: sample
10+
ms.workload: infrastructure
11+
ms.date: 02/23/2022
12+
ms.author: ramankum
13+
ms.custom: mvc
14+
---
15+
16+
# Copy snapshot of a managed disk to same or different subscription with CLI
17+
18+
This script copies a snapshot of a managed disk to same or different subscription. Use this script for the following scenarios:
19+
20+
- Migrate a snapshot in Premium storage (Premium_LRS) to Standard storage (Standard_LRS or Standard_ZRS) to reduce your cost.
21+
- Migrate a snapshot from locally redundant storage (Premium_LRS, Standard_LRS) to zone redundant storage (Standard_ZRS) to benefit from the higher reliability of ZRS storage.
22+
- Move a snapshot to different subscription in the same region for longer retention.
23+
24+
> [!NOTE]
25+
> Both subscriptions must be located under the same tenant
26+
27+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
28+
29+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
30+
31+
## Sample script
32+
33+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
34+
35+
### Run the script
36+
37+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-snapshot-to-same-or-different-subscription/copy-snapshot-to-same-or-different-subscription.sh" range="3-36":::
38+
39+
## Clean up resources
40+
41+
Run the following command to remove the resource group, VM, and all related resources.
42+
43+
```azurecli-interactive
44+
az group delete --name mySourceResourceGroupName
45+
```
46+
47+
## Sample reference
48+
49+
This script uses following commands to create a snapshot in the target subscription using the `Id` of the source snapshot. Each command in the table links to command specific documentation.
50+
51+
| Command | Notes |
52+
|---|---|
53+
| [az snapshot show](/cli/azure/snapshot) | Gets all the properties of a snapshot using the name and resource group properties of the snapshot. The `Id` property is used to copy the snapshot to different subscription. |
54+
| [az snapshot create](/cli/azure/snapshot) | Copies a snapshot by creating a snapshot in different subscription using the `Id` and name of the parent snapshot. |
55+
56+
## Next steps
57+
58+
[Create a virtual machine from a snapshot](./virtual-machines-linux-cli-sample-create-vm-from-snapshot.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)
59+
60+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
61+
62+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Copy a snapshot to a storage account in another region using the CLI
3+
description: Azure CLI Script Sample - Export/Copy snapshot as VHD to a storage account in same or different region.
4+
documentationcenter: storage
5+
author: ramankumarlive
6+
manager: kavithag
7+
ms.service: virtual-machines
8+
ms.subservice: disks
9+
ms.devlang: azurecli
10+
ms.topic: sample
11+
ms.workload: infrastructure
12+
ms.date: 02/23/2022
13+
ms.author: ramankum
14+
ms.custom: "mvc,seodec18"
15+
---
16+
17+
# Export/Copy a snapshot to a storage account in different region with CLI
18+
19+
This script exports a managed snapshot to a storage account in different region. It first generates the SAS URI of the snapshot and then uses it to copy it to a storage account in different region. Use this script to maintain backup of your managed disks in different region for disaster recovery.
20+
21+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
22+
23+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
24+
25+
## Sample script
26+
27+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
28+
29+
### Run the script
30+
31+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/copy-snapshots-to-storage-account/copy-snapshots-to-storage-account.sh" range="3-33":::
32+
33+
## Clean up resources
34+
35+
Run the following command to remove the resource group, VM, and all related resources.
36+
37+
```azurecli-interactive
38+
az group delete --name myResourceGroupName
39+
```
40+
41+
## Sample reference
42+
43+
This script uses following commands to generate SAS URI for a managed snapshot and copies the snapshot to a storage account using SAS URI. Each command in the table links to command specific documentation.
44+
45+
| Command | Notes |
46+
|---|---|
47+
| [az snapshot grant-access](/cli/azure/snapshot) | Generates read-only SAS that is used to copy underlying VHD file to a storage account or download it to on-premises |
48+
| [az storage blob copy start](/cli/azure/storage/blob/copy) | Copies a blob asynchronously from one storage account to another |
49+
50+
## Next steps
51+
52+
[Create a managed disk from a VHD](virtual-machines-cli-sample-create-managed-disk-from-vhd.md?toc=%2fcli%2fmodule%2ftoc.json)
53+
54+
[Create a virtual machine from a managed disk](virtual-machines-linux-cli-sample-create-vm-from-managed-os-disks.md?toc=%2fcli%2fmodule%2ftoc.json)
55+
56+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
57+
58+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Create managed disk from snapshot (Linux) - CLI sample
3+
description: Azure CLI Script Sample - Create a managed disk from a snapshot
4+
services: virtual-machines-linux
5+
documentationcenter: storage
6+
author: ramankumarlive
7+
manager: kavithag
8+
9+
tags: azure-service-management
10+
11+
ms.assetid:
12+
ms.service: virtual-machines-linux
13+
ms.devlang: azurecli
14+
ms.topic: sample
15+
ms.tgt_pltfrm: vm-linux
16+
ms.workload: infrastructure
17+
ms.date: 02/23/2022
18+
ms.author: ramankum
19+
ms.custom: mvc
20+
---
21+
22+
# Create a managed disk from a snapshot with CLI (Linux)
23+
24+
This script creates a managed disk from a snapshot. Use it to restore a virtual machine from snapshots of OS and data disks. Create OS and data managed disks from respective snapshots and then create a new virtual machine by attaching managed disks. You can also restore data disks of an existing VM by attaching data disks created from snapshots.
25+
26+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
27+
28+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
29+
30+
## Sample script
31+
32+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
33+
34+
### Run the script
35+
36+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/create-managed-disks-from-snapshot/create-managed-disks-from-snapshot.sh" range="3-30":::
37+
38+
## Clean up resources
39+
40+
Run the following command to remove the resource group, VM, and all related resources.
41+
42+
```azurecli-interactive
43+
az group delete --name myResourceGroupName
44+
```
45+
46+
## Sample reference
47+
48+
This script uses following commands to create a managed disk from a snapshot. Each command in the table links to command specific documentation.
49+
50+
| Command | Notes |
51+
|---|---|
52+
| [az snapshot show](/cli/azure/snapshot) | Gets all the properties of a snapshot using the name and resource group properties of the snapshot. Id property is used to create managed disk. |
53+
| [az disk create](/cli/azure/disk) | Creates a managed disk using snapshot Id of a managed snapshot |
54+
55+
## Next steps
56+
57+
[Create a virtual machine by attaching a managed disk as OS disk](./virtual-machines-linux-cli-sample-create-vm-from-managed-os-disks.md?toc=%2fcli%2fmodule%2ftoc.json)
58+
59+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
60+
61+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: Create a managed disk from a VHD file in the same account - CLI sample
3+
description: Azure CLI Script Sample - Create a managed disk from a VHD file in a storage account in the same subscription
4+
documentationcenter: storage
5+
author: ramankumarlive
6+
manager: kavithag
7+
ms.service: virtual-machines
8+
ms.subservice: disks
9+
ms.devlang: azurecli
10+
ms.topic: sample
11+
ms.workload: infrastructure
12+
ms.date: 02/23/2022
13+
ms.author: ramankum
14+
ms.custom: mvc
15+
---
16+
17+
# Create a managed disk from a VHD file in a storage account in the same subscription with CLI (Linux)
18+
19+
This script creates a managed disk from a VHD file in a storage account in the same subscription. Use this script to import a specialized (not generalized/sysprepped) VHD to managed OS disk to create a virtual machine. Or, use it to import a data VHD to managed data disk.
20+
21+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
22+
23+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
24+
25+
## Sample script
26+
27+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
28+
29+
### Run the script
30+
31+
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/create-managed-data-disks-from-vhd/create-managed-data-disks-from-vhd.sh" range="3-37":::
32+
33+
## Clean up resources
34+
35+
Run the following command to remove the resource group, VM, and all related resources.
36+
37+
```azurecli-interactive
38+
az group delete --name myResourceGroupName
39+
```
40+
41+
## Sample reference
42+
43+
This script uses following commands to create a managed disk from a VHD. Each command in the table links to command specific documentation.
44+
45+
| Command | Notes |
46+
|---|---|
47+
| [az disk create](/cli/azure/disk) | Creates a managed disk using URI of a VHD in a storage account in the same subscription |
48+
49+
## Next steps
50+
51+
[Create a virtual machine by attaching a managed disk as OS disk](./virtual-machines-linux-cli-sample-create-vm-from-managed-os-disks.md?toc=%2fcli%2fmodule%2ftoc.json)
52+
53+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
54+
55+
Additional virtual machine and managed disks CLI script samples can be found in the [Azure Linux VM documentation](../linux/cli-samples.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json).

0 commit comments

Comments
 (0)