Add device to Azure AD Group

Tim Nielsen 21 Reputation points
2022-10-26T11:20:41.703+00:00

I want to add a list of devices to a specific group in azure AD via the graph API.

I already have a list of both Device ID's and AADDeviceID's, but this endpoint only accepts objectids:
https://learn.microsoft.com/en-us/graph/api/group-post-members?view=graph-rest-1.0&tabs=http

So my question is, how do I get the ObjectID from Graph API

Bonus info:
This dosn't accept DeviceID
https://learn.microsoft.com/en-us/graph/api/device-get?view=graph-rest-1.0&tabs=http

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,239 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,893 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,128 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 71,626 Reputation points MVP
    2022-10-26T11:30:07.067+00:00

    The value you need is the "id", as returned from the GET /devices endpoint. Then pass the value in a /members/$ref POST request:

    GET https://graph.microsoft.com/v1.0/devices?$select=displayName,id  
      
    POST https://graph.microsoft.com/v1.0/groups/0d79d876-83a9-4845-bed8-a65e7633fb1b/members/$ref  
    {  
        "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/3cfaf4c5-4c2c-4f34-b160-6748e45b2c49"  
    }  
    

    254307-image.png


0 additional answers

Sort by: Most helpful