error Operation returned an invalid status code 'Forbidden' - status code 403

Syed Sadatullah Quadri 20 Reputation points
2025-05-28T01:40:20.4433333+00:00

Hi there
I'm doing online learning for Module AZ-104 and when I get to the part where I have to create a new resource using powershell. I get the following error. I tried logging off and signing back in a few times but this issue still persists. I seem to have 'Contributor' role. Can you please resolve this issue as I have been stuck on this module for quite some time and cannot move ahead. Thanks.

New-AzResourceGroup : Operation returned an invalid status code 'Forbidden'

StatusCode: 403

ReasonPhrase: Forbidden

OperationID : 13c62ff6-c3ff-49d3-8c2a-7f7280fcb5b5

At line:1 char:1

  • New-AzResourceGroup -Name SQresource -Location westus
  • 
        + CategoryInfo          : CloseError: (:) [New-AzResourceGroup], ResourceManagerCloudException
    
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupCmdlet
    
Azure | Azure Training
{count} votes

Accepted answer
  1. Pradeep M 9,770 Reputation points Microsoft External Staff Volunteer Moderator
    2025-05-28T12:21:07.4366667+00:00

    Hi Syed Sadatullah Quadri

    Thank you for reaching out to Microsoft Q & A forum.   

    The 403 Forbidden error appears because the Microsoft Learn sandbox allows deployments only to the pre created resource group (e.g., learn-xxxx). You won’t be able to create a new one like SQresource within the sandbox. 

    To proceed in the sandbox, please run: 

    Set-AzDefault -ResourceGroupName <your-sandbox-rg>  
    
    

    If you'd like to create your own resource group, consider using a Free Trial or your personal Azure subscription instead.
    Also, note that Units 1, 2, and 4 cover theoretical concepts, while Units 3 and 5 provide hands on exercises. 

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community. 


0 additional answers

Sort by: Most helpful

Your answer

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