How to add users to an application group in AVD using REST API?

Himanshu Nankani 71 Reputation points
2022-05-16T13:32:12.807+00:00

I have been trying to find how to add users to an app group. The options I got so far are from portal and through power shell script. But what I want is an API that can do the work. I have tried to use the API as described here
https://learn.microsoft.com/en-us/rest/api/virtual-desktop/app-group/add-user

It gives 401 : Unauthorised error though I do have the owner rights in my subscription. Also I am not really able to find out the tenant group name, so I tried to create one tenant group, but even that gives me unauthorised.

I observed that the REST APIs described under "Windows Virtual Desktop" in MS official docs are not working for me but the ones under the "Desktop Virtualisation" do work. So are those deprecated?

Please let me know if there is a way to achieve this.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,584 questions
Azure Virtual Desktop
Azure Virtual Desktop
A Microsoft desktop and app virtualization service that runs on Azure. Previously known as Windows Virtual Desktop.
1,451 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
329 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Himanshu Nankani 71 Reputation points
    2022-05-19T09:36:34.87+00:00

    I was able to figure it out from other source, but I am posting the answer here in case somebody else finds it helpful:

    So there is no direct API to add users, but there is this API you can find below which adds role assignment
    https://learn.microsoft.com/en-us/rest/api/authorization/role-assignments/create-by-id#create-role-assignment-by-id

    Using the given API we can assign this role '1d18fff3-a72a-46b5-b4a9-0b38a3cd7e63' and provide the user principal id (we can get user details from graph API)
    (Ref. https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles).

    To conclude this role assignment is equivalent to adding user to the app group.

    1 person found this answer helpful.