SOLVED

Azure Labs Services user has not enough permissions

%3CLINGO-SUB%20id%3D%22lingo-sub-2456484%22%20slang%3D%22en-US%22%3EAzure%20Labs%20Services%20user%20has%20not%20enough%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2456484%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20login%20to%20the%20portal%20Azure%20Labs%20Services%20and%20I%20can%20list%20the%20user%20of%20specified%20labs%2C%26nbsp%3B%20but%20when%20I%20use%20this%20operations%20using%20API%20Azure%20Labs%20Services%2C%20I%20get%20this%20error%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%3E%3CSPAN%20class%3D%22hljs-attr%22%3E%22error%22%3C%2FSPAN%3E%3A%20%7B%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-attr%22%3E%22code%22%3C%2FSPAN%3E%3A%20%3CSPAN%20class%3D%22hljs-string%22%3E%22AuthorizationFailed%22%3C%2FSPAN%3E%2C%0A%20%20%20%20%3CSPAN%20class%3D%22hljs-attr%22%3E%22message%22%3C%2FSPAN%3E%3A%20%3CSPAN%20class%3D%22hljs-string%22%3E%22El%20client%20%5C%22xxxxxx%40.onmicrosoft.com%5C%22%20with%20object%20id%20%20%5C%22XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX%5C%22%20does%20not%20have%20authorization%20to%20perform%20%20action%20%20%5C%22Microsoft.LabServices%2Fusers%2FlistLabs%2Faction%5C%22%20over%20scope%20%5C%22%2Fproviders%2FMicrosoft.LabServices%2Fusers%2Fuser9E172B8798321F4B4A2407BF604385325063A940F9CB74EEDDF108B962C28E39%5C%22%20%20%3C%2FSPAN%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Flabservices%2Fglobal-users%2Flist-labs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Flabservices%2Fglobal-users%2Flist-labs%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eplease%20help%20me%2C%26nbsp%3B%20I%20don't%20known%20what%20permission%20I%20require%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2458727%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Labs%20Services%20user%20has%20not%20enough%20permissions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2458727%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F92662%22%20target%3D%22_blank%22%3E%40Manuel%20Munayco%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20permission%20you%20need%20is%20'Microsoft.LabServices%2Fusers%2FlistLabs%2Faction'%20as%20noted%20in%20the%20error%20message.%20To%20check%20what%20permissions%20you%20have%20on%20a%20particular%20asset%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Frole-based-access-control%2Fcheck-access%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Frole-based-access-control%2Fcheck-access%3C%2FA%3E.%26nbsp%3B%20This%20comes%20with%20roles%20like%20owner%2C%20contributor%2C%20lab%20creator.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20trying%20to%20create%20a%20custom%20role%20that%20can%20access%20labs%2C%20I%20would%20suggest%20reading%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-lab-services%2Fuse-custom-role-to-tailor-teachers-lab-management-permissions%2Fba-p%2F2113016%22%20target%3D%22_blank%22%3EUse%20Custom%20Role%20to%20Tailor%20Teachers'%20Lab%20Management%20Permissions%20-%20Microsoft%20Tech%20Community%3C%2FA%3E.%26nbsp%3B%20It%20lists%20all%20the%20permissions%20and%20what%20they%20do.%26nbsp%3B%20Also%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-lab-services%2Flab-liaison-custom-role%2Fba-p%2F2323761%22%20target%3D%22_blank%22%3ELab%20Liaison%20Custom%20Role%20-%20Microsoft%20Tech%20Community%3C%2FA%3E%26nbsp%3Bmight%20be%20helpful.%26nbsp%3B%20It%20is%20a%20how-to%20for%20creating%20custom%20roles%20and%20covers%20the%20minimum%20roles%20needed%20for%20using%20the%20Labs%20Portal.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20these%20articles%20are%20not%20able%20to%20solve%20your%20issue%2C%20could%20you%20please%20respond%20back%20with%20an%20overview%20of%20what%20your%20are%20trying%20to%20accomplish%3F%26nbsp%3B%20It%20sounds%20like%20you%20trying%20to%20create%20a%20tool%20that%20uses%20the%20Lab%20Services%20api%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%3C%2FP%3E%0A%3CP%3EElizabeth%20Maher%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi All, 

 

I login to the portal Azure Labs Services and I can list the user of specified labs,  but when I use this operations using API Azure Labs Services, I get this error

 

"error": {
    "code": "AuthorizationFailed",
    "message": "El client \"xxxxxx@.onmicrosoft.com\" with object id  \"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXX\" does not have authorization to perform  action  \"Microsoft.LabServices/users/listLabs/action\" over scope \"/providers/Microsoft.LabServices/users/user9E172B8798321F4B4A2407BF604385325063A940F9CB74EEDDF108B962C28E39\"   

 

https://docs.microsoft.com/en-us/rest/api/labservices/global-users/list-labs

 

please help me,  I don't known what permission I require 

3 Replies

@Manuel Munayco,

 

The permission you need is 'Microsoft.LabServices/users/listLabs/action' as noted in the error message. To check what permissions you have on a particular asset see https://docs.microsoft.com/en-us/azure/role-based-access-control/check-access.  This comes with roles like owner, contributor, lab creator.

 

If you are trying to create a custom role that can access labs, I would suggest reading Use Custom Role to Tailor Teachers' Lab Management Permissions - Microsoft Tech Community.  It lists all the permissions and what they do.  Also, Lab Liaison Custom Role - Microsoft Tech Community might be helpful.  It is a how-to for creating custom roles and covers the minimum roles needed for using the Labs Portal.

 

If these articles are not able to solve your issue, could you please respond back with an overview of what your are trying to accomplish?  It sounds like you trying to create a tool that uses the Lab Services api?

 

Thanks,

Elizabeth Maher

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.

best response confirmed by Manuel Munayco (New Contributor)
Solution

@Manuel Munayco 

 

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

https://management.azure.com/providers/Microsoft.LabServices/users/NoUsername/listAllEnvironments?ap... 

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