Share via

Getting a "does not have authorization" error when trying to create Linux VM with Az Powershell in sandbox

Wesley Sherwood 50 Reputation points
2024-01-06T01:13:18.6666667+00:00

Edit: I solved the issue myself.

So I am working through the "Automate Azure tasks using scripts with Powershell" training, and on unit 6 I am trying to create the Linux VM in the example.

I am running the cmdlet they provide.

New-AzVm -ResourceGroupName [learn-bf7b5d31-00eb-4cfb-ab13-4b9d780f86cb] -Name "testvm-eus-01" -Credential (Get-Credential) -Location "eastus" -Image Canonical:0001-com-ubuntu-server-focal:20_04-lts:latest -OpenPorts 22 -PublicIpAddressName "testvm-eus-01"

I enter my credentials as requested, and I get a long error

New-AzVM: The client 'live.com#****' with object id '-a98c-d88119fb22e5' does not have authorization to perform action 'Microsoft.Compute/virtualMachines/read' over scope '/subscriptions/f26515d9-3bc6-4a50-8192-cb816a833f54/resourceGroups/[learn-bf7b5d31-00eb-4cfb-ab13-4b9d780f86cb]/providers/Microsoft.Compute/virtualMachines/testvm-eus-01' or the scope is invalid. If access was recently granted, please refresh your credentials.

How do I proceed?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Mohammed Altamash Mohammed Suleman Khan 2,416 Reputation points
    2024-01-08T21:44:20.5633333+00:00

    Hi Wesley Sherwood

    Give user RBAC role like CONTRIBUTOR in subscription - 95815503-8b5e-4bcb-a98c-d88119fb22e5 ( Try to hide part of your subscription ID on public portals). that should resolve your issue

    ------------If you find this answer helpful , Kindly accept the answer ----------------


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.