Prerequisites
- Azure Subscription: You need an Azure account. You can sign up for a free account if you don’t have one.
- Microsoft Graph Explorer: Access Microsoft Graph Explorer.
Step 1. Create an App Registration
To use Microsoft Graph, you must register an application in Azure AD.
- Navigate to Azure Portal: Go to the Azure portal.
- Select Azure Active Directory: In the left-hand menu, click on "Azure Active Directory."
- Register a New Application
- Click on "App registrations."
- Click on "+ New registration."
- Enter a name for your application (e.g., "CustomAttributesApp").
- Select the supported account types (e.g., "Accounts in this organizational directory only").
- Click "Register."
- Copy Application (Client) ID: After registration, note the Application (client) ID from the application overview page. You'll need this ID later.
Step 2. Create a Custom Extension Attribute
Now that we have an app registration let's create a custom extension attribute.
- Open Graph Explorer: Access Graph Explorer.
- Authenticate: Click on "Sign in to Graph Explorer" to authenticate with your Azure account.
- GET Request for Application
- Create Extension Attribute
- Note the Extension Attribute Name: The response will include the full attribute name in the format.
For example
- Code: extension_cde0e9a5d3f44a81b81097334dbb9f66_Birthday
Step 3. Populate the Custom Extension Attribute on a User
Next, we’ll populate this attribute for a specific user.
- Find User ID
- To find users in Azure AD, navigate back to the Azure portal.
- Click on "Users" under Azure Active Directory.
- Select a user to view their details. You can note their Object ID or User Principal Name (UPN).
- Patch User with Extension Attribute
- In Graph Explorer, set the method to PATCH.
- Enter the resource URI for the user:
- Code: PATCH https://graph.microsoft.com/v1.0/users/{user objectId or upn}
- Add the request body to set the extension attribute value.
- Code: { "extension_cde0e9a5d3f44a81b81097334dbb9f66_Birthday": "2000-11-05T11:40:09Z" }
- Click "Run Query." If you get an HTTP 204 response, the patch is successful.
Step 4. Retrieve Custom Extension Attribute on a User
Now, let's retrieve the custom extension attribute to confirm it has been populated.
Get User Details
- Set the method to GET in Graph Explorer.
- Enter the resource URI.
- Code: GET https://graph.microsoft.com/v1.0/users/{user objectId or upn}?$select=id,displayName,userPrincipalName,extension_cde0e9a5d3f44a81b81097334dbb9f66_Birthday
or
- Code: GET https://graph.microsoft.com/beta/users/{user objectId or upn}
- Click "Run Query." You should see the user details along with the custom attribute.
Output
Note on Permissions
- If you encounter any errors related to permissions while using Graph Explorer, ensure that you check the "Modify Permissions" section. In the status column, look at the image below. It is all okay. If you see a "Consent" button in blue, click on it to grant the necessary permissions. This should resolve your issue.
- Additionally, if you cannot find certain features or attributes in the v1.0 version, try using the beta version of Microsoft Graph Explorer, as it may have the functionality you need.
Conclusion
You've successfully created a custom extension attribute in Azure AD and populated it with data using Microsoft Graph. This feature allows you to store additional information that can be useful for your organization's needs.
Thank you for reading!
If you have any questions or need further assistance, feel free to leave a comment below.