az vm repair

Auto repair commands to fix VMs.

VM repair command will enable Azure users to self-repair non-bootable VMs by copying the source VM's OS disk and attaching it to a newly created repair VM.

Commands

az vm repair create

Create a new repair VM and attach the source VM's copied OS disk as a data disk.

az vm repair list-scripts

List available scripts. Located https://github.com/Azure/repair-script-library.

az vm repair restore

Replace source VM's OS disk with data disk from repair VM.

az vm repair run

Run verified scripts from GitHub on a VM. 'az vm repair list-scripts' to view available scripts.

az vm repair create

Create a new repair VM and attach the source VM's copied OS disk as a data disk.

az vm repair create --name
                    --resource-group
                    [--copy-disk-name]
                    [--repair-group-name]
                    [--repair-password]
                    [--repair-username]
                    [--repair-vm-name]
                    [--unlock-encrypted-vm]

Examples

Create a repair VM

az vm repair create -g MyResourceGroup -n myVM --verbose

Create a repair VM and set the VM authentication

az vm repair create -g MyResourceGroup -n myVM --repair-username username --repair-password password!234 --verbose

Required Parameters

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--copy-disk-name

Name of OS disk copy.

--repair-group-name

Repair resource group name.

--repair-password

Admin password for the repair VM.

--repair-username

Admin username for repair VM.

--repair-vm-name

Name of repair VM.

--unlock-encrypted-vm

Option to auto-unlock encrypted VMs using current subscription auth.

az vm repair list-scripts

List available scripts. Located https://github.com/Azure/repair-script-library.

az vm repair list-scripts

Examples

List scripts

az vm repair list-scripts --verbose

List windows scripts only.

az vm repair list-scripts --query "[?starts_with(id, 'win')]"

List scripts with test in its description.

az vm repair list-scripts --query "[?contains(description, 'test')]"

az vm repair restore

Replace source VM's OS disk with data disk from repair VM.

az vm repair restore --name
                     --resource-group
                     [--disk-name]
                     [--repair-vm-id]
                     [--yes]

Examples

Restore from the repair VM, command will auto-search for repair-vm

az vm repair restore -g MyResourceGroup -n MyVM --verbose

Restore from the repair VM, specify the disk to restore

az vm repair restore -g MyResourceGroup -n MyVM --disk-name MyDiskCopy --verbose

Required Parameters

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--disk-name

Name of fixed data disk. Defaults to the first data disk in the repair VM.

--repair-vm-id

Repair VM resource id.

--yes

Deletes the repair resources without confirmation.

az vm repair run

Run verified scripts from GitHub on a VM. 'az vm repair list-scripts' to view available scripts.

az vm repair run --name
                 --resource-group
                 [--custom-script-file]
                 [--parameters]
                 [--repair-vm-id]
                 [--run-id]
                 [--run-on-repair]

Examples

Run the script with <run-id> directly on the VM.

az vm repair run -g MyResourceGroup -n MySourceWinVM --run-id win-hello-world --verbose

Run the script with <run-id> on the linked repair VM.

az vm repair run -g MyResourceGroup -n MySourceWinVM --run-id win-hello-world --run-on-repair --verbose

Run a script with parameters on the VM.

az vm repair run -g MyResourceGroup -n MySourceWinVM --run-id win-hello-world --parameters hello=hi world=earth --verbose

Run a local custom script on the VM.

az vm repair run -g MyResourceGroup -n MySourceWinVM --custom-script-file ./file.ps1 --verbose

Required Parameters

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--custom-script-file

Custom script file to run on VM. Script should be PowerShell for windows, Bash for Linux.

--parameters

Space-separated parameters in the format of '[name=]value'. Positional for bash scripts.

--repair-vm-id

Repair VM resource id.

--run-id

Unique run id for run scripts.

--run-on-repair

Script will be run on the linked repair VM.