The virtual machine must be running before using vmaccess.

How to reset password in Azure virtual machine

In this Azure tutorial, we will discuss how to fix the error the virtual machine must be running before using vmaccess. That I got while I was trying to change Azure VM Password.

The virtual machine must be running before using vmaccess.

Change Azure VM Password

Let’s discuss how can we reset the password of the virtual machine in the Azure portal.

You can follow the below steps to reset the password for the virtual machine

Step- 1: 

Login to https://portal.azure.com/

Step- 2: 

Search for Virtual machines there.

Azure virtual machine reset password

Step- 3: 

 You will see the list of VMs created in your Azure subscription. It will show the VM name, Type, Status, ResourceGroup, Location, etc.

azure vm change password

Step- 4: 

Now click on the VM name. “MyNewVM” in my case. You can see the details of your virtual machine like Public IP address, status, Computer name, Operating system, Size, etc.

how to reset root password in azure linux vm

Step- 5:

Select the Reset Password option under support + troubleshooting from the left side menu.

azure reset linux vm password

Step- 6:

As you will see in the below screen, the Reset password option is disabled, and it is not allowing me to change the password and saying, “The virtual machine must be running before using VMAccess“. Check out the screenshot below.

the virtual machine must be running before using vmaccess.

This is because maybe my VM status is Stopped (deallocated) or not running. Let’s check that.

You can see below the VM status is Stopped (deallocated). Now to fix the error “the virtual machine must be running before using vmaccess.” click the start button. After that, the VM status will be Running.

azure vm reset password

Step- 7:

Now, if you click on the Reset Password option again, you can see the Reset Password option is enabled.

Choose the Mode as Reset password.

Enter the username and password, confirm the password, and click the Update button.

Reset Azure VM Password PowerShell

This is how you can reset your VM password from the Azure portal.

Change Azure VM Password using PowerShell

Well, let’s discuss how to reset Azure VM password using PowerShell.

Step- 1:

First, connect to the Azure account using the below command.

Connect-AzAccount 

Step- 2:

Select the Azure subscription ID

$MySubID = "<Mention Your Subscription ID>"
Select-AzSubscription -SubscriptionId $MySubID 

Step- 3:

Set the Set-AzVMAccessExtension to reset the username or password.

$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Now, below is the complete Powershell script

$MySubID = "<Mention Your Subscription ID>"
$MyResourceGroup = "<Mention your Resource group name>" 
$MyVmName = "<Mention your VM name>" 
$MyLocation = "<Mention your VM Location>" 

Connect-AzAccount 
Select-AzSubscription -SubscriptionId $MySubID
Set-AzVMAccessExtension -ResourceGroupName $MyResourceGroup -Location $MyLocation -VMName $MyVmName -Credential (get-credential) -typeHandlerVersion "2.0" -Name VMAccessAgent 

Change Azure VM Password using Azure CLI

We have discussed above how to reset passwords for Azure VM using Azure Portal and PowerShell. You can also reset the password for your Azure Virtual machine using Azure CLI using the below quick steps.

  1. Open the Azure CLI from the Azure Portal.
  2. Run the below cmdlt to reset or change the password using Azure CLI.
az vm user update
 -n {Your Virtual Machine name}
 -g {Name of your resource group}
-u {Your username}
 -p {Your password}

Example:

az vm user update
 -n TSINFOVM
 -g Demo12
-u User1 -p Password@12345

If are you facing any issues while resetting the password of your Azure VM, then check out Azure VM Password Reset Not Working to get a solution.

Change / Reset Password of Virtual machine (VM) – Video Tutorial

FAQs

How To Find Azure VM Username And Password

No need to worry if you have missed your Azure virtual machine username and password. You can able to reset the username and password using the below steps:

Follow Steps 1 to 7 to reset the username and password from the “How to reset password in Azure virtual machine” section above.

You may like the following Azure tutorials:

Conclusion

In this Azure tutorial, We discussed the quick steps to change Azure VM Password. I hope you have enjoyed this article !!!