Hello marouf,
I understand you are trying to follow Demo 01: Administer Identity alongside Lab 02a: Manage Subscriptions and RBAC, and you're seeing an error when trying to create a custom role using the New-AzRoleDefinition
command.
The error "NotFound" usually occurs when there's a problem with the values defined in the role file. To check the file content being used, you can run:
Get-Content -Path "$HOME/az104-02a-customRoleDefinition.json"
In many cases, this happens when the "AssignableScopes"
section includes a management group or subscription that doesn't exist or isn't accessible.
To confirm that the scope values are valid, run the following:
Get-AzManagementGroup
Get-AzSubscription
Please check whether a management group named az104-02-mg1
has been created. If the name in your JSON doesn't match exactly, the command will fail. Scope names must be precise, including hyphens and casing.
After updating the name to the correct one, command succeeded:
New-AzRoleDefinition -InputFile $HOME/az104-02a-customRoleDefinition.json
Make sure you're working within the right subscription context:
Get-AzContext
Set-AzContext -SubscriptionId "<your-subscription-id>"
Also, confirm that your account has either Owner or User Access Administrator permissions, as these are required for custom role creation.
Hope this clarifies things a bit!
If the issue still persists, please share your contact details and time zone in the Private Message window so we can connect offline and help resolve it.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful, which may help members with similar questions.
If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.