Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / microsoft-graph

Microsoft Graph integration

The Microsoft Graph integration provides a focused view of the Entra directory. It supports application registration and service-principal discovery for clients such as Terraform. It also exposes groups and direct membership so clients can relate a token identity to directory access. All Graph reads and membership changes use the same default-tenant directory that supplies Entra token identities.

Directory model

The directory model links users, groups, applications, and service principals. A user's object ID is the stable identity used across tokens, group membership, and Graph responses. Application registrations also create matching service principals, so application clients can discover the principal used by the token service.

The Graph slice presents these relationships as directory resources:

  • Users identify people and can be resolved by object ID or user principal name.
  • Groups contain direct member links and expose user, group, or service-principal members.
  • Applications represent app registrations and their client credentials.
  • Service principals represent the tenant-local form of an application.

Graph resource surface

The service accepts a narrow /v1.0 resource set rather than acting as a general Microsoft Graph server. The resource surface supports the client flows that need directory discovery, application setup, and group access.

ResourcePurpose
applicationsCreate, find, update, and remove app registrations.
applications/{id}/addPassword and removePasswordManage client secrets for an app registration.
applications/{id}/owners and owners/$refList, add, or remove application owners.
servicePrincipalsFind the service principal for an application ID.
groupsList groups and optionally include their members.
users/{id}/getMemberGroupsReturn the user's direct group IDs, with an optional security-group filter.
groups/{id}/members/$refAdd a direct member to a group.
groups/{id}/members/{memberId}/$refRemove a direct member from a group.

Application writes preserve the properties that clients send and return the registration in the shape expected by Graph clients. A new registration receives both an application ID and a service principal. The signed-in principal becomes the first owner, followed by valid owners named in the request. A client secret is returned only when it is created; later application reads expose credential metadata without the secret value.

Application discovery supports exact filters on appId, displayName, or id, plus prefix filters on appId or displayName. Updates replace only the properties named by the client. Deletion removes the linked service principal with the application.

References: src/…/GraphApplications.java• L33-47 src/…/GraphApplications.java• L76-126 src/…/GraphApplications.java• L129-192 src/…/GraphApplications.java• L251-350 src/…/GraphApplications.java• L396-426

Service-principal discovery

Service-principal discovery maps an application ID to the tenant's service-principal object ID. This lets a client use the same principal identity when it starts from an application registration or from a token issued by Entra.

When a client sends the common appId filter, the integration returns the matching principal. A known application uses its stored principal ID. An unknown application still receives a stable fallback object so bootstrap clients can complete their discovery step without service-principal CRUD.

References: src/…/GraphServiceHandler.java• L190-210

Group membership

Group membership exposes direct links in the shared directory. getMemberGroups accepts a user object ID or user principal name and returns sorted group IDs. With securityEnabledOnly, the result keeps only security-enabled groups. The operation does not expand nested groups.

The group list can filter by exact id or displayName, or by a set of values with in. Clients can request direct members with $expand=members. Membership changes use the member ID from @odata.id; the link is stored even when that member is not currently a stored user. This matches the narrow reference-link behavior of the integration.

The following flow shows how an identity moves between token issuance and Graph membership lookup.

sequenceDiagram
    participant Client
    participant Entra as Entra token service
    participant Graph as Microsoft Graph slice
    participant Directory as Default tenant directory

    Client->>Entra: Request token
    Entra->>Directory: Resolve user identity
    Directory-->>Entra: User object ID
    Entra-->>Client: Token with oid
    Client->>Graph: getMemberGroups(oid or UPN)
    Graph->>Directory: Read direct group links
    Directory-->>Graph: Group IDs
    Graph-->>Client: Group ID collection

References: src/…/GraphServiceHandler.java• L98-187 src/…/GraphServiceHandler.java• L212-255

Routing and tenant scope

Graph requests use the /v1.0/ path shape and are handled as the graph service. The service is controlled by the Graph enablement setting. Requests in this slice use the configured default tenant, while response metadata uses the cloud endpoint associated with the request.

Unsupported resources return Graph-style errors. Unsupported methods on a known resource return 405. Invalid filters and malformed membership references return 400, while missing directory resources return 404.

References: src/…/GraphServiceHandler.java• L74-123 src/…/GraphServiceHandler.java• L260-295 src/…/GraphApplications.java• L607-623

The Graph identity is designed to agree with Entra identity behavior. The oid claim in a token identifies the same user object that Graph resolves. Group IDs are available through the membership operation rather than being added to authorization-code tokens by default. See Azure identity and security for token and claim behavior, and Cloud directory configuration for the directory and tenant model.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep application creation and deletion aligned with service-principal discovery so an app ID always maps to the expected tenant principal.
  • Keep user object IDs consistent between token oid claims and getMemberGroups lookups by object ID or user principal name.
  • Preserve direct-link semantics when changing group reads or membership writes. Do not silently add nested-group expansion.
  • Keep supported group filter forms aligned with the Graph query clients that use eq, in, and $expand=members.
  • Preserve one-time secret exposure and metadata-only application reads when changing application credential behavior.
  • Keep application owner links aligned with owner references and the signed-in principal used during registration.
  • Keep Graph enablement, default-tenant selection, cloud response metadata, and endpoint routing aligned when the service surface changes.

Important failure modes

TriggerConsequenceGuard
A client looks up an unknown usergetMemberGroups returns 404 Request_ResourceNotFoundResolve by object ID or user principal name before reading links
A group filter uses an unsupported field or expressionThe group request returns 400 Request_BadRequestLimit filters to id or displayName with eq or in
A membership request omits a usable @odata.idThe add request returns 400 and creates no linkParse a non-blank reference and use its trailing member ID
A client expects nested groups or token group claimsThe result does not include those groupsUse direct membership lookup and treat token oid as the identity key
An app is deleted while its principal remains expectedDiscovery can return stale or missing application stateRemove the linked service principal with the application
A client expects a secret in a later application readThe read contains credential metadata but no secret valueCapture the value from the successful addPassword response
An owner reference names no stored user or service principalApplication creation or owner addition returns 404Bind only existing directory principals

Key files

FileWhy to read it
src/…/GraphServiceHandler.javaDefines the Graph resource surface, directory reads, membership flow, and tenant scope.
src/…/GraphApplications.javaDefines application registration, service-principal creation linkage, owner links, and client-secret behavior.
src/…/GroupFilter.javaDefines the supported group query forms.
src/…/DirectoryReader.javaShows how Graph resolves users, groups, and service principals from the Entra directory.
src/…/GraphDirectoryStore.javaShows the shared directory records and direct membership links used by Graph and token flows.