az vm repair
Note
This reference is part of the vm-repair extension for the Azure CLI (version 2.0.67 or higher). The extension will automatically install the first time you run an az vm repair command. Learn more about extensions.
Setup repair VMs with copied source OS Disk to resolve issues.
When your VM is non-bootable, VM Repair enables users to setup new repair VMs and copy over the source VM's OS Disk and attach it as a data disk. Then the user can run their own scripts or use pre-built ones to fix the disk.
Commands
Name | Description | Type | Status |
---|---|---|---|
az vm repair create |
Create a new repair VM and attach the source VM's copied OS disk as a data disk. |
Extension | GA |
az vm repair list-scripts |
List available scripts. Located https://github.com/Azure/repair-script-library. |
Extension | GA |
az vm repair repair-and-restore |
Repair and restore the VM. |
Extension | Preview |
az vm repair repair-button |
Repair button script. |
Extension | Preview |
az vm repair reset-nic |
Reset the network interface stack on the VM guest OS. https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/reset-network-interface. |
Extension | Preview |
az vm repair restore |
Replace source VM's OS disk with data disk from repair VM. |
Extension | GA |
az vm repair run |
Run verified scripts from GitHub on a VM. 'az vm repair list-scripts' to view available scripts. |
Extension | GA |
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
[--associate-public-ip]
[--copy-disk-name]
[--disable-trusted-launch]
[--distro]
[--enable-nested]
[--encrypt-recovery-key]
[--os-disk-type]
[--repair-group-name]
[--repair-password]
[--repair-username]
[--repair-vm-name]
[--unlock-encrypted-vm]
[--yes]
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
Create a repair VM of a specific distro or a specific URN could also be provided
az vm repair create -g MyResourceGroup -n myVM --distro 'rhel7|sles12|ubuntu20|centos6|oracle8|sles15'
Create a repair VM with a Private IP address without any pop up asking for confirmation.
az vm repair create -g MyResourceGroup -n myVM --yes --repair-username <username> --repair-password <password>
Create a repair VM with a Public IP address without any user input.
az vm repair create -g MyResourceGroup -n myVM --associate-public-ip --yes --repair-username <username> --repair-password <password>
Create a repair VM with Standard Security type.
az vm repair create -g MyResourceGroup -n myVM --yes --repair-username <username> --repair-password <password> --disable-trusted-launch
Create a repair VM from a source VM with an encrypted disk. The repair VM is created with the data disk unencrypted and accessible.
az vm repair create -g MyResourceGroup -n myVM --yes --repair-username <username> --repair-password <password> --unlock-encrypted-vm --encrypt-recovery-key <key>
Create a repair VM with an OS Disk storage type of StandardSSD_LRS.
az vm repair create -g MyResourceGroup -n myVM --yes --repair-username <username> --repair-password <password> --os-disk-type StandardSSD_LRS
Required Parameters
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Option to create a repair vm with a public ip. If this parameter is not used, a private ip will be made.
Property | Value |
---|---|
Default value: | False |
Name of OS disk copy.
Option to disable Trusted Launch security type on the repair vm by setting the security type to Standard.
Property | Value |
---|---|
Default value: | False |
Option to create repair vm from a specific linux distro (rhel7|rhel8|sles12|sles15|ubuntu20|centos7|centos8|oracle7).
Property | Value |
---|---|
Default value: | ubuntu |
Enable nested hyperv.
Property | Value |
---|---|
Default value: | False |
Option to auto-unlock encrypted VMs using provided recovery password. The '--unlock-encrypted-vm' parameter must be used to use this parameter.
Change the OS Disk storage type from the default of PremiumSSD_LRS to the given value.
Name for new or existing resource group that will contain repair VM.
Admin password for the repair VM.
Admin username for repair VM.
Name of repair VM.
Option to auto-unlock encrypted VMs using current subscription auth.
Property | Value |
---|---|
Default value: | False |
Option to skip prompt for associating public ip in no Tty mode.
Property | Value |
---|---|
Default value: | False |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm repair list-scripts
List available scripts. Located https://github.com/Azure/repair-script-library.
az vm repair list-scripts [--preview]
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')]"
List unverified script from your fork of https://github.com/Azure/repair-script-library
az vm repair list-scripts --preview "https://github.com/User/repair-script-library/blob/main/map.json"
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
URL of forked repair script library's map.json https://github.com/{user}/repair-script-library/blob/master/map.json.
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm repair repair-and-restore
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Repair and restore the VM.
az vm repair repair-and-restore [--copy-disk-name]
[--ids]
[--name]
[--repair-group-name]
[--repair-password]
[--repair-username]
[--repair-vm-name]
[--resource-group]
[--subscription]
Examples
Repair and restore a VM.
az vm repair repair-and-restore --name vmrepairtest --resource-group MyResourceGroup --verbose
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Name of OS disk copy.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name for new or existing resource group that will contain repair VM.
Admin password for the repair VM.
Admin username for repair VM.
Name of repair VM.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm repair repair-button
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Repair button script.
az vm repair repair-button --button-command
[--copy-disk-name]
[--ids]
[--name]
[--repair-group-name]
[--repair-password]
[--repair-username]
[--repair-vm-name]
[--resource-group]
[--subscription]
Examples
repair-button.
az vm repair repair-button --name vmrepairtest --resource-group MyResourceGroup --button-command fstab --verbose
Required Parameters
Button_command for repair VM.
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Name of OS disk copy.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name for new or existing resource group that will contain repair VM.
Admin password for the repair VM.
Admin username for repair VM.
Name of repair VM.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm repair reset-nic
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Reset the network interface stack on the VM guest OS. https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/reset-network-interface.
az vm repair reset-nic [--ids]
[--name]
[--resource-group]
[--subscription]
[--yes]
Examples
Reset the VM guest NIC. Specify VM resource group and name.
az vm repair reset-nic -g MyResourceGroup -n MyVM --verbose
Reset the VM guest NIC. Specify subscription id, VM resource group and name.
az vm repair reset-nic -g MyResourceGroup -n MyVM --subscription mySub --verbose
Reset the VM guest NIC and auto-start the VM if it is not in running state.
az vm repair reset-nic -g MyResourceGroup -n MyVM --yes --verbose
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Do not prompt for confirmation to start VM if it is not running.
Property | Value |
---|---|
Default value: | False |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
az vm repair restore
Replace source VM's OS disk with data disk from repair VM.
az vm repair restore [--disk-name]
[--ids]
[--name]
[--repair-vm-id]
[--resource-group]
[--subscription]
[--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
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Name of fixed data disk. Defaults to the first data disk in the repair VM.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Repair VM resource id.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Deletes the repair resources without confirmation.
Property | Value |
---|---|
Default value: | False |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |
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 [--custom-script-file]
[--ids]
[--name]
[--parameters]
[--preview]
[--repair-vm-id]
[--resource-group]
[--run-id]
[--run-on-repair]
[--subscription]
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 verified script with some parameters. In the first parameter named 'key', only the value 'test' is sent to the script. The second parameter named 'initiator', uses the prefix '++' to send the entire following string 'initiator=selfhelp' to the script.
az vm repair run -g MyResourceGroup -n MySourceWinVM --run-id linux-alar2 --parameters key=test ++initiator=selfhelp --verbose --debug
Run a local custom script on the VM.
az vm repair run -g MyResourceGroup -n MySourceWinVM --custom-script-file ./file.ps1 --verbose
Run unverified script from your fork of https://github.com/Azure/repair-script-library
az vm repair run -g MyResourceGroup -n MySourceWinVM --preview "https://github.com/User/repair-script-library/blob/main/map.json" --run-id test
Optional Parameters
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
Custom script file to run on VM. Script should be PowerShell for windows, Bash for Linux.
One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Space-separated parameters in the format of '[name=]value'. Positional for bash scripts. To avoid splitting on =, use the prefix '++' to send the entire string.
URL of forked repair script library's map.json https://github.com/{user}/repair-script-library/blob/master/map.json.
Repair VM resource id.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Unique run id for run scripts.
Script will be run on the linked repair VM.
Property | Value |
---|---|
Default value: | False |
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Property | Value |
---|---|
Parameter group: | Resource Id Arguments |
Global Parameters
Increase logging verbosity to show all debug logs.
Property | Value |
---|---|
Default value: | False |
Show this help message and exit.
Only show errors, suppressing warnings.
Property | Value |
---|---|
Default value: | False |
Output format.
Property | Value |
---|---|
Default value: | json |
Accepted values: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath query string. See http://jmespath.org/ for more information and examples.
Increase logging verbosity. Use --debug for full debug logs.
Property | Value |
---|---|
Default value: | False |