Share via

I am getting below error while creating an VM

Arvind Ingole, Shilpa 20 Reputation points
2024-10-18T06:42:53.7066667+00:00

I tried below command using sandbox

az create vm

and I got following message,
(AuthorizationFailed) The client '******@capgemini.com' with object id '6f5c92a9-539e-474f-b372-22fabca30b6b' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/read' over scope '/subscriptions/16982123-2d3c-44ce-ab2d-0c419f4ce699/resourcegroups/learn-1e24dbde-a766-4692-8d0f-92bb6773cd43' or the scope is invalid. If access was recently granted, please refresh your credentials.

Code: AuthorizationFailed

Message: The client '******@capgemini.com' with object id '6f5c92a9-539e-474f-b372-22fabca30b6b' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/read' over scope '/subscriptions/16982123-2d3c-44ce-ab2d-0c419f4ce699/resourcegroups/learn-1e24dbde-a766-4692-8d0f-92bb6773cd43' or the scope is invalid. If access was recently granted, please refresh your credentials.

This question is related to the following Learning Module

Azure | Azure Training

Answer accepted by question author

Anonymous
2024-10-18T07:00:18.5733333+00:00

Hi Arvind Ingole, Shilpa,

Note: Kindly do not share any PII data (e.g email ID) on the public forum for your privacy and security. 

We extend our gratitude for your participation in the Microsoft Q&A forum. 

Based on our understanding of the issue, you are practicing the following Learn path exercise.  

Create an Azure virtual machine under Task 1: Create a Linux virtual machine and install Nginx we have two steps:  

Step 1: To create a Linux VM using "az vm create" command and  

Step 2: To configure Nginx on the VM created using "az vm extension set" command.  

As mentioned in the exercise, we have used generate-ssh-keys for authentication while creating the VM using "az vm create" command rather than a password.  

The "az vm extension set" command uses the Custom Script Extension to run a Bash script on your VM to configure Nginx.  

We can successfully create a Linux VM and configure Nginx on the VM created by following the above steps of Task 1 and complete the exercise without any password. Kindly find the screenshots attached for reference.
User's image

User's image We don’t have to manually run the command "sudo apt-get update" separately. The Custom Script Extension used in "az vm extension set" command to run a Bash script takes care of invoking "sudo apt-get update" automatically with elevated permissions. By running the script, the command automatically runs 'sudo apt-get update' with the saved SSH key files.  

If we manually run the command "sudo apt-get update"(not required as per the exercise), the system prompts us to enter a password.  
User's image As we have used SSH key pairs for authentication rather than a password, we cannot enter a password.  

If we want to connect to the VM created (without a password in this case for Linux VM) we need to do ssh to the vm created, before we can use sudo.  

After completing Step 1, create a Linux VM of Task 1, make a note of the publicIpAddress that was assigned to the VM
Connect to the newly created VM using ssh (in cloud shell). We need to substitute the publicIpAddress noted above for <VM public ip address> in the command below:  

"ssh azureuser@<VM public ip address>"  

Enter 'yes' when you are prompted. 
User's image Now we have successfully connected to the VM without using password and we can work in the VM. We can see our VM name as "my-vm" in the screenshot below which is same as given in "az vm create" command.  

Please don't hesitate to reach out to us if you have any further queries. I hope the information provided has been helpful to you! If so, please accept the answer by clicking the Accept Answer / Upvote on the post. We value your feedback, and it will help to assist others who might have a similar query. Thank you for your contribution in enhancing Microsoft Q&A!

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.