Forum Discussion
Azure Labs Services user has not enough permissions
- Jun 17, 2021
Ah, gotcha.
The API you are calling is one of the global api, not attached to a specific subscription. It's meant to be called by a user to get their own information. So a call to
would list all the info for the VMs (including lab name) that are assigned to the user describe in the Auth bearer token passed in with the call to the API.
If you are trying to get the labs for a specific user that is not you, it's a little trickier. If possible for your situation I would recommend trying out PowerShell module for Azure Lab Services - Azure Lab Services | Microsoft Docs. For example
Get-AzLabAccount | Get-AzLab | Get-AzLabUser -email 'email@contoso.com'
would get the info for the user associated with the email 'email@contoso.com' including labs the user has registered for.
Get-AzLabAccount | Get-AzLab | Get-AzLabUser -email 'email@constoso.com' | select -expand 'id' | %{ $_.Substring(0,$_.IndexOf("/users"))}
would get the resource id for each lab the user is registered for.
If you have to use the Lab Services API directly, you'll need to get all the labs, then all the users for each of your labs and then match the email address.
Hope that helps,
Elizabeth
Thks for your answer planetmaher
I am using the API of LabServices to list the users and their corresponding labs. It is in this action where I get this error. Other operations like list account lab or labs work fine.
But the way, the user that I use is owner at the subscription level and I also see that I have activated the Microsoft.LabServices resource provider.
Do you think that if I have the owner role at the subscription level, I still need some custom role.
Ah, gotcha.
The API you are calling is one of the global api, not attached to a specific subscription. It's meant to be called by a user to get their own information. So a call to
would list all the info for the VMs (including lab name) that are assigned to the user describe in the Auth bearer token passed in with the call to the API.
If you are trying to get the labs for a specific user that is not you, it's a little trickier. If possible for your situation I would recommend trying out PowerShell module for Azure Lab Services - Azure Lab Services | Microsoft Docs. For example
Get-AzLabAccount | Get-AzLab | Get-AzLabUser -email 'email@contoso.com'
would get the info for the user associated with the email 'email@contoso.com' including labs the user has registered for.
Get-AzLabAccount | Get-AzLab | Get-AzLabUser -email 'email@constoso.com' | select -expand 'id' | %{ $_.Substring(0,$_.IndexOf("/users"))}
would get the resource id for each lab the user is registered for.
If you have to use the Lab Services API directly, you'll need to get all the labs, then all the users for each of your labs and then match the email address.
Hope that helps,
Elizabeth