Introduction to Microsoft Graph

Implement Azure Security for Developers

Anushika Agarwal

Cloud Data Engineer

What is Microsoft Graph?

  • Unified API to access Microsoft 365 data

  • One endpoint for all services

Microsoft Graph - One endpoint for all services

Implement Azure Security for Developers

Example: PeopleSphere with Microsoft Graph

  • PeopleSphere uses:

    • Outlook for leave requests
    • Teams for HR meetings
    • OneDrive for payslips
  • Graph connects them all

How PeopleSphere uses Microsoft Graph

Implement Azure Security for Developers

Anatomy of a Graph API call

Unified API: One endpoint to access Microsoft Cloud service resources Microsoft Graph API Request

Implement Azure Security for Developers

Breaking down the request

  • Request Components:

    • Method: GET, POST, PATCH, etc.

    • Version: v1.0, beta

    • Resource: users, groups,etc.

    • Query Parameters: $select, $filter

    • Headers: Authorization, Content-Type

Microsoft Graph API Request

Implement Azure Security for Developers

Methods

  • Supported Methods:

    • GET: Retrieve data

    • POST: Create new data

    • PUT: Replace data completely

    • PATCH: Update existing data

    • DELETE: Remove data

Implement Azure Security for Developers

Versioning: v1.0

  • https://graph.microsoft.com/v1.0/groups

  • Stable APIs

  • Generally available APIs
  • Used for production apps

Versioning - v1.0

Implement Azure Security for Developers

Versioning: beta

beta

  • https://graph.microsoft.com/beta/groups
  • Preview, experimental features
  • Unstable, may break
  • Testing only, not production

`

Versioning - Beta

Implement Azure Security for Developers

Resource

  • The specific data you're interacting.

  • Example:

    • Users: Access information about users
      • /users, /me
    • Groups: Work with groups
      • /groups
    • Events: Retrieve calendar events
      • /users/{userId}/events

Users

Groups

Events

Implement Azure Security for Developers

Query parameters

  • Options to filter, sort, or select specific data

  • Select:

    • Choose specific fields
    • $select=id,displayName
  • Filter:

    • Filter data
    • $filter=startswith(displayName, 'John')
  • Top:

    • Limit the number of results
    • $top=5

Query Parameters - Select

  Query Parameters - Filter

  Query Parameters - Top

Implement Azure Security for Developers

Headers

Carry meatadata in HTTP requests and responses

Two types of headers: Standard & API-Specific

Headers

  • Standard: Common to all requests
    • Authorization: Bearer {access_token}
    • Content-Type: application/json
  • API-Specific: Vary by API
    • Retry-After: 30
    • Location: https://graph.microsoft.com/operationStatus
Implement Azure Security for Developers

Let's practice!

Implement Azure Security for Developers

Preparing Video For Download...