Azure Day 3: Create VM using Azure CLI Issue Access

I am facing the below issue while trying to create azure vm command in the kode kloud engineer lab

az vm create
–name “nautilus-vm”
–resource-group “kml_rg_main-dfa697ea5e8c4a7f”
–location “WestUS”
–image Ubuntu2204
–size Standard_B2s
–admin-username azureuser
–nsg-rule SSH
–storage-sku Standard_LRS
–os-disk-size-gb 30
–generate-ssh-keys

Issue log
(AuthorizationFailed) The client ‘a1a7e8ab-cadd-4a55-8240-e45af853fb03’ with object id ‘2df58d70-9f31-46d7-956a-5f9f57e0d743’ does not have authorization to perform action ‘Microsoft.Resources/subscriptions/resourcegroups/read’ over scope ‘/subscriptions/f0c3bcdd-5ce2-4fa0-8cf3-41559747512b/resourcegroups/kml_rg_main-dfa697ea5e8c4a7f’ or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed
Message: The client ‘a1a7e8ab-cadd-4a55-8240-e45af853fb03’ with object id ‘2df58d70-9f31-46d7-956a-5f9f57e0d743’ does not have authorization to perform action ‘Microsoft.Resources/subscriptions/resourcegroups/read’ over scope ‘/subscriptions/f0c3bcdd-5ce2-4fa0-8cf3-41559747512b/resourcegroups/kml_rg_main-dfa697ea5e8c4a7f’ or the scope is invalid. If access was recently granted, please refresh your credentials.

Hi @Pavithran-N

Did you check the resource-group with az group list -o table command?

And the location is not mentioned in the task, which might be causingthe issue, try removing it and using the correct resource group.

This minimum set of flags should work.

az vm create \
  --resource-group <resource-group> \  # Get the resource-group from above command
  --name nautilus-vm \
  --image Ubuntu2204 \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys \
  --storage-sku Standard_LRS \
  --os-disk-size-gb 30
1 Like

Yes , i have followed the shared command after that it worked