Map ARM and Graph to Different APIs and Identities
Two control planes answer two different questions. Azure Resource Manager decides what exists inside a subscription. Microsoft Graph decides who exists inside the directory. A root module can hold both, but no single request crosses between them.
The endpoint fixes the audience. ARM calls go to management.azure.com, Graph calls go to graph.microsoft.com, and a token minted for one is refused by the other before any permission is evaluated. That refusal is the cheapest diagnostic in this article: it says the request went to the wrong plane, not that a role is missing.
One credential can obtain both tokens. The same Entra application or managed identity asks for an ARM token and a Graph token, and all three providers can resolve that same credential chain. Sharing a credential is convenient. It does not merge the two authorization systems, and it does not make one role assignment cover both.
Identifiers never convert. An ARM resource is a path through a subscription and a provider namespace; a directory object is addressed by object ID under /applications or /servicePrincipals. No parser rewrites one into the other.
The bridge is a stored attribute, not a translation. Both planes report the same client ID for an application, and an ARM identity exports a principal ID that Graph also knows. Those values are the join key for a handoff, and copying them by hand is where most of them go wrong.
Authorization is evaluated where the object lives. Azure RBAC answers at a management group, subscription, resource group or resource scope. Graph answers at the directory through app roles, delegated scopes and admin consent, with no subscription or resource group anywhere in the path.
Graph ownership is a grant, not a courtesy. The Application.ReadWrite.OwnedBy role lets a principal manage only the applications it owns, while Application.ReadWrite.All reaches every application in the tenant. That difference decides whether a handoff adds an owner to the app object or asks for a tenant-wide permission with admin consent.
The failure messages point at different teams. An ARM denial names the scope and the missing action, which is an RBAC ticket. A Graph denial names the permission, the consent state or the missing owner, which is a directory ticket. Sending one to the other team is how a one-hour fix becomes a two-week negotiation.
A subscription Owner is not a directory administrator. Owner grants ARM write and role assignment at a scope and grants nothing in Graph. Global Administrator can consent to Graph permissions and still have no ARM write. Two planes, two approvals, two audit trails.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
P["terraform plan
resource address in the graph"] --> C["One credential
Entra app, user or managed identity"]
C --> Q{"Which provider
owns this address?"}
Q -->|"azurerm_*"| A["ARM token
management.azure.com"]
Q -->|"azapi_*"| A
Q -->|"azuread_*"| G["Graph token
graph.microsoft.com"]
A --> AR["Azure RBAC evaluated
management group, subscription,
resource group or resource"]
G --> GR["Graph evaluated
app role, scope, consent, owner"]
AR -->|"no role at this scope"| X1["403 AuthorizationFailed
names the scope"]
GR -->|"no permission or owner"| X2["403 Insufficient privileges
names the directory grant"]
AR --> OK1["ARM object written
azurerm or azapi"]
GR --> OK2["Directory object written
azuread"]
X1 --> R["Fix the authorization store
that rejected the call"]
X2 --> R
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class P,C primary;
class Q,A,G secondary;
class AR,GR,OK1,OK2 ok;
class X1,X2 danger;
class R warn;
Figure 1 splits at token acquisition, not at the API call. One plan can exercise both planes, and the two failure paths never converge: each error names the store that refused it.
Figure 2 shows the boundary the shared credential does not remove. The credential sits above both planes because it can serve both. The authorization stores sit inside their own plane and never consult each other.
Read the table as an address book, not a feature list. It records what each plane calls an object and who is allowed to write it, which is the information a handoff actually needs.
| Plane | Object identity | Authorized by | Terraform resources | Failure signature |
|---|---|---|---|---|
| ARM control plane | resource path through a subscription and provider namespace | Azure RBAC at a management group, subscription, resource group or resource | azurerm_*, azapi_* | 403 naming the scope and the missing action |
| Graph applications | object ID under /applications | app roles such as Application.ReadWrite.OwnedBy, delegated scopes, admin consent, owner list | azuread_application, azuread_application_registration | 403 naming the permission, consent or owner |
| Graph service principals | object ID under /servicePrincipals | app roles and ownership, created along with an ARM managed identity | azuread_service_principal for directory principals only | object exists but no address manages it |
| Role assignments | ARM assignment GUID at a scope versus an app-role assignment on a resource principal | written by the plane that owns the grant | azurerm_role_assignment, azuread_app_role_assignment | a grant that exists in the wrong plane |
Two providers can share a credential and still fail at different moments. A plan that authenticates for both proves nothing about either authorization. The next section is about the other kind of choice: which provider should write the object at all.
Choose a Companion Provider for a Verified Gap
Preference is not evidence. Choosing AzAPI because it feels more direct, or AzureAD because a tutorial used it, produces a second owner with no capability gain. A companion provider is justified by a named gap: a resource type AzureRM does not model, a property the typed schema does not carry, or an object that exists only in the directory.
Verify the gap against the build you run. Read the resource list for 5.13.0, not the provider's main branch, and confirm the property in the schema rather than in a release note. A preview resource in the documentation can be absent from the binary your lock file selects.
AzAPI's cost is the untyped body. You supply a resource type with an api-version, a parent ID and a body that mirrors the REST payload. Terraform stores what you sent and compares what comes back, so every server-populated field becomes yours to explain.
Two defaults decide how quiet the diff is. ignore_missing_property defaults to true, so a property the API stops returning disappears from the plan instead of showing as drift. ignore_body_changes is a write-only argument whose value is stored in provider-private state, so a change to it only takes effect after an apply.
Schema validation is local, not authoritative. The provider checks the type and body against a bundled schema before sending anything. That catches shape errors early; it cannot predict a service-side rule, a regional restriction or a quota.
An api-version is a lifecycle commitment. Preview versions retire, and a retired version turns a clean plan into an error months after the handoff. Record the version beside the provider pin and put a review date on it, because the object will outlive the decision.
AzureAD is for directory objects only. Applications, service principals, groups, federated credentials and app-role assignments live in Graph. Nothing about them belongs in an ARM resource, and no Azure role makes them writable.
The 3.x split changes what one object means. azuread_application_registration owns the application object, while identifier URIs, redirect URIs and API permissions are separate resources with separate addresses. Adopting the registration alone leaves those facets unmanaged, which is a half-handoff that plans cleanly and breaks at the first sign-in.
AzAPI has a narrow second shape. azapi_update_resource writes a subset of properties on a resource whose lifecycle belongs elsewhere, and deleting it leaves those properties in place. That makes it a property writer, not an owner; use it only where the property is explicitly outside the lifecycle owner's configuration, and say so in the module.
Gap closure is the next handoff. When AzureRM ships the typed resource, the reason for AzAPI disappears and ownership must move again. Plan that transfer instead of keeping both, because a resource that has been typed is exactly the one that will drift under an untyped body.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
G["Name the gap
type, property or directory object"] --> A{"azurerm 5.13.0
models it?"}
A -->|"yes"| A1["Stay with azurerm
no companion needed"]
A -->|"no"| B{"Is it a directory object?"}
B -->|"yes"| B1["azuread 3.10.0
Graph permission and consent"]
B -->|"no"| C{"azapi exposes the type
at a named api-version?"}
C -->|"no"| C1["Leave it outside Terraform
record the external owner"]
C -->|"yes, preview"| D["AzAPI with a review date
and an exit path"]
C -->|"yes, supported"| E["AzAPI resource
type, parent, body"]
D --> F{"Rehearsal passes?"}
E --> F
F -->|"no"| F1["Stop: the gap is unverified
do not adopt the object"]
F -->|"yes"| H["One owner, one address
record version and date"]
A1 --> H
B1 --> H
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class G,A1,H primary;
class A,B,C,D,E,F secondary;
class B1 ok;
class C1,F1 danger;
class D warn;
Figure 3 makes the gap the entry condition. Every branch except the first is a claim that something is missing. The rehearsal branch is what turns a claim into a decision.
Prevent Dual Ownership During a Handoff
Dual ownership is two writers, not two files. The same object can be claimed from one state or from two, and the outcome is identical: each apply writes its view of the payload and the other side plans a revert. The loop is invisible until two applies land close together.
Start from a proven no-change baseline. Apply the current owner, confirm an empty plan and back up state before editing anything. Without that baseline, the first post-handoff diff mixes the transfer with drift that was already there.
Prefer a short unmanaged window to a long dual-managed one. terraform state rm removes the address from state and leaves the remote object untouched. For the minutes between removal and import the object is unmanaged, which a re-import can recover. While both addresses exist it is double-managed, which no plan can repair.
Import is adoption, not a move. terraform import refreshes the remote object into the new address; it changes nothing in Azure and refuses an address that already holds state. So the order is fixed: remove the old address, import into the new one, then plan.
Never destroy the old owner to release it. A destroy of the old resource deletes the object the new owner is about to adopt. Removing the address from state is the only release that leaves the object in place, and it is the step reviewers most often want to skip.
moved blocks do not cross providers. A moved block renames an address inside one provider's schema; it cannot turn an AzureRM resource into an AzAPI resource. The transfer is state surgery and belongs in a reviewed change, not in a refactor commit.
For Graph objects, count the facets before moving one. A registration plus identifier URIs plus redirect URIs plus API permissions is four addresses for one application. Import all four or the destroy of the old comprehensive resource removes the facets you did not adopt.
Two AzureAD resources on one application is the same mistake in a smaller frame. The comprehensive and lightweight application resources both write the display name and the sign-in audience, and the provider says plainly that they must not manage the same application. Holding both to compare them is dual ownership with a Graph token.
The managed identity trap is not a handoff at all. A user-assigned identity resource already causes a service principal to exist, and the principal ID it exports is that object. Declaring a directory service principal resource for the same client ID gives one directory object two owners, and destroying the wrong one removes the principal that every role assignment references.
Role assignments do not travel with the object. An ARM assignment points at a principal ID, so recreating a principal leaves grants pointing at the old one. Re-point the assignments in the same change and read one of them back before calling the handoff complete.
Detect overlap mechanically. terraform state list plus a search of the plan JSON for the remote ID finds two addresses on one object in seconds. A review checklist finds only what someone remembered to look for.
Figure 4 makes the window explicit. The middle stage is the only one where nobody owns the object, and it is deliberately short. The panel below it is the state that teams drift into when they add the new resource before removing the old one.
Compare Plans Before and After the Transfer
Compare three plans, not two. The baseline before any edit, the plan immediately after the import, and a second plan after an apply that changed nothing. The middle plan proves adoption; the last proves convergence.
Use the exit code as the gate. A plan with no changes exits 0, a plan with changes exits 2 under -detailed-exitcode, and an error exits 1. A pipeline that only reads the rendered text has a report, not a gate.
Read actions before values. Every address should be a no-op or, at most, an in-place update you can name. A create means the import landed on the wrong address. A replace means the new configuration does not describe the object that already exists.
Normalized values are the usual false diff. Location casing, tag ordering, identity block shape and empty lists differ between what you wrote and what the API returns. A provider that normalizes them plans clean; one that does not shows a cosmetic update on every run.
AzAPI normalizes asymmetrically. The body you send is a subset of the body you get back, and missing properties are ignored by default. A clean plan therefore means "the API returned nothing that contradicts my body", which is weaker than "the configuration and the object agree".
The Graph side has invisible fields too. The application object reports a publisher domain and an application ID that no configuration sets. Those are computed values; a plan that tries to write them is a configuration error, not drift.
Compare identifiers, not counts. Two states can hold the same number of addresses and still point at different objects. Pull the ID from each state entry after the import and compare the set.
Do not make the plan clean by changing the object. If the only way to reach an empty plan is to let the new owner rewrite a property, the handoff changed behaviour. That belongs in the decision record, not in the diff.
Keep the plan JSON, not a screenshot. The JSON produced by terraform show -json can be diffed, hashed and searched for an ID by the next reviewer; a terminal screenshot proves only that someone looked once.
Figure 5 sorts the post-import plan into three verdicts. Only the first is acceptance. The second needs a sentence in the change record, and the third needs the handoff rolled back rather than explained away.
Accept the Change on Stable Behavior and Ownership
Acceptance is four claims, each with its own evidence. The plan is empty on a second run, the remote identifiers are unchanged, the workload still works, and exactly one address owns each object. A clean plan proves the first and says nothing about the other three.
Behaviour is checked from the consumer side. A role assignment that still resolves, a secret that still reads, an application that still signs in: pick the operation the object exists for and run it after the handoff. Terraform's read of the object is not the consumer's view of it.
Ownership is checked from state, not from the config. Count the addresses that hold each remote ID. Two addresses on one ID is the dual-ownership state from the previous section, and it can appear after a handoff just as easily as during one.
Recovery is the reverse handoff, written down before the forward one. Remove the new address from state, import the old one, restore the previous configuration and plan. That path is only available while the old configuration still exists, so keep the commit and the state backup until the new owner has survived a full apply cycle.
A handoff that cannot be reversed is a migration. If the old provider cannot describe the object any more, the decision is permanent and belongs with the other irreversible changes, not in a routine refactor.
Publish the record, not the identifiers. Provider versions, the api-version, plan hashes, the identifier set, the consumer check and the date belong in the change record. Subscription IDs, tenant IDs and object IDs stay in the internal system of record.
The card below runs the whole exercise on one disposable root, with a resource group for the ARM side and an application for the Graph side.
Accept the Change on Stable Behavior and Ownership
Status: design-only. No Azure subscription or tenant was touched for this article, and none of these steps were executed here. Every identifier is a placeholder you supply in your own sandbox tenant, and the root is disposable.
Prerequisites. Terraform CLI 1.17.1 with hashicorp/azurerm 5.13.0, azure/azapi 2.13.0 and hashicorp/azuread 3.10.0, a sandbox subscription, permission to create a resource group, and permission to create an app registration in the test tenant. Cost is effectively zero: one empty resource group, one app registration and one user-assigned identity.
Setup. One root, local state, and three objects chosen to exercise a different mechanism each: a resource group, an app registration with only a display name, and a user-assigned identity. The group is owned by the typed AzureRM resource, the application by the comprehensive AzureAD resource, and the identity by its ARM resource.
The app deliberately has no identifier URI or redirect URI, so the handoff is one facet; a production application usually has several.
| Move | What it tests | Expected result |
|---|---|---|
Resource group to azapi_resource | ARM object adopted by a second provider | empty plan, same resource ID |
App registration to azuread_application_registration | Graph object adopted across the 3.x split | empty plan, same object ID |
| Identity principal | a second owner must not be added | one address holds the principal ID |
- Apply the baseline, record the resource ID, the application object ID and the identity principal ID, then plan with
-detailed-exitcodeand confirm exit code 0. - Back up the state file and note the backend version, so the reversal has a reference point.
- Add the
azapi_resourceblock for the resource group on a branch, with the type pinned to a specific api-version and the body copied from a read of the object. Do not apply it yet. - Remove
azurerm_resource_group.sandboxfrom state, confirm the group still exists in the portal or CLI, then import it intoazapi_resource.sandboxusing the resource ID. - Plan. Expect no changes and the same resource ID. A create means the import missed the address; a replace means the body does not describe the group.
- Remove
azuread_application.labfrom state and import it intoazuread_application_registration.labusing the same/applications/{objectId}form. Both resources accept that string, which is why this step is easy to get wrong. - Plan again and confirm the application object ID is unchanged. If the old resource owned identifier URIs or redirect URIs, expect creates for the companion resources; that is the facet count, not a failure.
- Search state for the identity principal ID and confirm exactly one address holds it. Then reverse the resource-group handoff, plan, and confirm exit code 0 before destroying the root.
- Run the consumer check for each object: read the group through the ARM API and read the application by client ID through Graph, both with the workload identity rather than the pipeline identity. The returned identifiers must match the baseline.
Expected observation. The post-import plans are empty, both remote IDs are identical to the baseline, and the identity principal has one owner. The reverse handoff plans clean as well, which is the evidence that the forward one is reversible.
Failure check. A create after import means the address or the import ID is wrong. A replace means the new configuration describes a different object than the one that exists. A Graph 403 means the running identity is neither an owner of the application nor holding a tenant-wide application permission. A missing companion resource means the facet count was wrong, not that the import failed.
Evidence to keep. The baseline and post-import plan JSON, the two identifier sets, the provider and api-version pins, the state list output, and the reverse-handoff transcript with exit codes. Sanitize tenant, subscription and object identifiers before the record leaves the team.