Forum Discussion

manuellmc's avatar
manuellmc
Copper Contributor
Jun 17, 2021

Azure Labs Services user has not enough permissions

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": { "c...
  • planetmaher's avatar
    planetmaher
    Jun 17, 2021

    manuellmc 

     

    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?api-version=2019-01-01-preview 

    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

Resources