How to create a new SSH key in Azure and use it to access a VM?

To create a new SSH key

1- Login to azure portal and go to the search bar and search "SSH Key" and click on the option.

2- On that panel you will see a Create option click on it and you will see a panel opened same like below.

3- Fill the details and click "Review + Create" button.

4- After it is created click on this newly created key, you will see a public key "Public key" copy it and past this while resting the key which I have explained in this video

5- Give any username and past the public key you just copied from above step and click update.

6- Now you will be able to login into VM by using this new user and ssh key.

7- But still your old key will work to login

8- To stop your old key you will need to login into VM and open the file by using the command "sudo nano ./.ssh/authorized_keys" you will see more than one public keys, comment the one you want to stop. You can compare the one you just created, keep this new one and comment others. To comment, just add/prepend # before key at first place.

By doing this all other keys will stop working and only newly created key will work to login to VM.