Error: User is not authorized to query the management service

Copper Contributor

When following the directions below, I always run into an error related to querying the management service.

 

https://docs.microsoft.com/en-us/azure/virtual-desktop/create-host-pools-azure-marketplace

 

Error message from the Azure portal:

"error": { "code": "VMExtensionProvisioningError", "message": "VM has reported a failure when processing extension 'dscextension'. Error message: \"DSC Configuration 'FirstSessionHost' completed with error(s). Following are the first few: PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: User is not authorized to query the management service.

 

I'm logged in as a user that in the global admin role in Azure AD, and it's also a user in the Windows Virtual Desktop enterprise application.  I've consented to the graph and Azure AD permissions under the enterprise app as well, any ideas?

59 Replies
I have the same problem. Does anyone have some ideas?
I'm getting the exact same thing. Any news or updates on this?
Could this be my problem? The instructions point to infrastructure requirements which says it needs the following things.....
-An Azure Active Directory
-A Windows Server Active Directory in sync with Azure Active Directory.
-An Azure subscription, containing a virtual network that either contains or is connected to the Windows Server Active Directory.

I don't have a local ad synced to azure ad. I only have azure ad.
The instructions seems to refer that you need all of it.

@Christopher Anderson , @Patrick F , @Seth Zwicker : The reason you see the "User is not authorized to query the management service" from the DSC extension is because the user who you provided in the last blade (where you also defined your Windows Virtual Desktop tenant name) does not have permissions in the tenant that you specified. A couple things you can check:

  • Did you create a tenant from these steps: https://docs.microsoft.com/azure/virtual-desktop/tenant-setup-azure-active-directory ?
  • Can you login to Windows Virtual Desktop with the username you provided in the last blade of Azure Marketplace offering, and does it require MFA to login? If that account does require MFA, it will not work when running as part of the script because there's no UI to prompt you for that second factor.
  • After logging in with that user account, can you run "Get-RdsTenant" to make sure that same Windows Virtual Desktop tenant shows appears?
  • Double/triple check that you entered the right values in the Azure Marketplace offering. For the most part, the Windows Virtual Desktop tenant group name should remain as "Default Tenant Group" and make sure to enter the Windows Virtual Desktop tenant name you created earlier, not a new one.

Thanks for testing and your patience here. We're compiling this same information and generating a Troubleshooting guide that hopefully should help you get unblocked yourself!

@Christopher Anderson 

 

I have the same issue too after following the instructions.

 

 New-RdsTenant -Name 'projectstest' -AadTenantId xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx -AzureSubscriptionId xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
New-RdsTenant : User is not authorized to query the management service.
ActivityId: xxxxxxx-9dec-485a-82ee-xxxxxxxxxxx
Powershell commands to diagnose the failure:
Get-RdsDiagnosticActivities -ActivityId xxxxxxx-9dec-485a-82ee-xxxxxxxxxx
At line:1 char:1
+ New-RdsTenant -Name 'projectstest' -AadTenantId xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : FromStdErr: (Microsoft.RDInf...nt.NewRdsTenant:NewRdsTenant) [New-RdsTenant], RdsPowerSh
ellException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.RDInfra.RDPowershell.Tenant.NewRdsTenant
Followed the guide here https://docs.microsoft.com/en-us/azure/virtual-desktop/tenant-setup-azure-active-directory

Turned off MFA for the account.


Granted permissions for client and server here https://rdweb.wvd.microsoft.com/

Granted permissions here for Virtual desktop https://aad.portal.azure.com

@Christian_Montoya I checked those steps again and I'm still not sure what I'm missing.  I reproduced the error outside of the template in PowerShell by doing the following:

 

1.  Created a new user account in Azure AD and put it in the TenantCreator role for Windows Virtual Desktop.

2.  Opened PowerShell as an admin, and added / logged into the account above using Add-RdsAccount

3.  Attempted to call Remove-RdsTenant as part of clean up to try and see if I could execute the template from scratch2019-03-27 12_28_22-Administrator_ Windows PowerShell.png

I was able to work around this issue.  Here is what I noted:

 

1.  Regardless of account, you don't seem to be able to delete existing tenant groups once their created using the Remove-RdsTenant account.  I always get the "user is not authorized to query the management service" error no matter what I do.

2.  Also, one of the steps I may have missed the first time is that the tenant group name you create via PowerShell has to match to what you create via the Azure portal.  After creating a new tenant group in Powershell separate from the default one, it worked when I referenced the new tenant group name in the Azure portal.  Hopefully at some point, Microsoft will have an end-to-end solution for creating the tenant, tenant group name, and host pool all within the portal. 

@Christopher Anderson : Just to clarify, the "tenant group" name should always be "Default Tenant Group". Only in very few circumstances does this change. But yes, you always need to provide the same "tenant" name everywhere you go.

@Christopher Anderson : Yes, I definitely support the last message, that one of our goals is to have all of this functionality straight from the Azure portal, without having to hop around everywhere.

 

Thank you for all of the feedback, and keep it coming!

Maybe it helps someone getting WVD up and running: https://erjenrijnders.nl/2019/04/04/how-to-deploy-windows-virtual-desktop-in-azure/ Using the service principal with the correct permissions worked for me.

@Erjen Rijnders, firstly thank you for pulling together that post and the associated PowerShell. It certainly makes the first steps for setting up WVD easier. However, my efforts in this are still failing on that last step in the Azure deployment /dscextension with the error:

 

" PowerShell DSC resource MSFT_ScriptResource  failed to execute Set-TargetResource functionality with error message: User is not authorized to query the management service."

 

I'm wondering exactly what the step is doing? I've remoted on to the VM which gets created and tired trawling through the event logs but there are no more details. I have also tried using just a UPN rather than your suggestion of service principle. It is a real head scratcher!

 

I'm going to go off and create a brand new AAD tenant and AAD DS resource just to rule out anything related to our existing corporate AAD tenant. Wish me luck :)

Hi @andrewstollery, Thanks and welcome. What is the result of this command?
Get-RdsRoleAssignment

You should set something like this.

rdsowner.jpg

 

Especially, the appid must be the same as the app you created earlier:
New-RdsRoleAssignment -RoleDefinitionName "RDS Owner" -ApplicationId $svcPrincipal.AppId -TenantGroupName $myTenantGroupName -TenantName $myTenantName -HostPoolName $hostpoolname

That AppID must be the same as the app you visited in the Azure Portal, creating te new key and used during the deployment of the Azure Marketplace WVD template.

And make sure, that the user you are using joining the VM's to the domain, is also having Owner access on the Azure subscription.
It needs to be able to run PowerShell DSC on the VM's.

@Erjen Rijnders 

 

Hey i am also have the same issue i followed both the microsoft guide and Erjen guild and failing on the DSCextension. I am thinking the problem is with AADDS. Has anyone made it work with AADDS?

 


thanks

@Stavros Mitchell, I have not tested with AAD DS, but from what I know, in the preview version you need a working AD Connect, meaning that you can only use an onprem AD. I hope they remove it from the production version.

Hi @Erjen Rijnders, thank you for the prompt reply. Given the number of times I've run this now, I actually get 5 RoleAssigmentIds returned...oops. How do I tidy those up? Using Remove-RdsRoleAssigment I guess? I'll have a crack at that later...

 

The last one in the list though is the correct one:

Screenshot 2019-04-10 at 14.18.02.png

 

I guess the only difference for me is that I am using AAD DS too, which you stated below is not supported. I'm not sure why not? I can get the VM to join the AAD DS domain. It is the DSCextension step which fails.

 

Anyhow, I'll do some tidying up and also keep progressing with my greenfield AAD, AAD DS and WVD deployment.

@andrewstollery, you did create a new key within that app from the Azure Portal right? And you used that key during deployment on step 4?

And the user you are using deploying the VM's, does have owner rights on the Azure Subscription?

I agree it should work, however with AAD DS you don't have access to the RPC-service. So that could be the reason it doesn't work. But still curious if you checked the points I just mentioned.

@andrewstollery 

 

I am pretty sure the issue is AADDS. I think i will set up a VM for active directory and link it to AADDS and see if that corrrects my issue

 

Hi Erjen,

Yes, my friend, I created my service principles key and used that. I listened to everything you wrote, you know what you are doing so I didn't want to assume anything :). I also doubled checked the VM deployment user is Owner on the subscription and it is.

I really appreciate your help with this, thank you for replying.

Alright, than it must be the AAD DS limitation indeed..