Skip to content

A Caller keyword tests the identity making the request

Context and Problem Statement

Azure Policy can test who makes a request, not just what it asks for, through requestContext().identity (Learn: using request context identity, updated 2026-07-08; Tech Community, 2026-11-05). A claim is read with tryGet(requestContext().identity, '<claim>'), in a value condition:

{ "value": "[tryGet(requestContext().identity, 'appid')]", "notIn": "[parameters('allowedClientAppIds')]" }

Learn lists these claims, "at a high level", so not necessarily all of them:

Claim Meaning
idtyp The caller's type: app, user, or null
appid The client application's ID
acrs Authentication context class references, comma-separated (such as p1 for a step-up policy)
http://schemas.microsoft.com/identity/claims/objectidentifier The caller's object ID, a user or service principal

Learn's other points:

  • Enforcement at request time applies to deny, modify and deployIfNotExists. The blog also uses denyAction.
  • Compliance scans of such a policy are marked NotApplicable.
  • Claims can be missing, which is why tryGet is used. It then returns null.
  • Neither page says whether the feature is in preview or generally available.

Bylaw can already write this, since Arm can be piped to Must (ADR-0025):

Arm "[tryGet(requestContext().identity, 'appid')]" | Must -BeIn (Param AllowedClientAppIds)

That compiles to Learn's example exactly (checked 2026-11-28). But the expression and the object ID claim's URI are hard to read, and two behaviours are easy to get wrong without help from the compiler:

  • A missing claim. In a Require, Must -BeIn is inverted to notIn, which is true for null, so a request without the claim is denied. That is usually the safe outcome, but nothing in the source says so, unlike a missing field, where the author chooses with -IfPresent (ADR-0003, ADR-0004).
  • Effects and compliance. Under Audit or AuditIfNotExists the policy never reports anything, and its compliance state is always NotApplicable.

Should Bylaw have a keyword for the caller's identity, and how should a missing claim behave?

Decision Drivers

  • Reads like the rest of the language: Caller AppId | Must -BeIn (Param AllowedClientAppIds).
  • A missing claim behaves as the author intends, and the source shows it.
  • The checks Azure can't do at authoring time are done at build time.
  • Claims Learn doesn't list yet can still be used.
  • ConvertTo-Bylaw can write the keyword back from the JSON (ADR-0039).

Considered Options

  • A Caller value keyword, with named claims and -Claim for others
  • Document the Arm pattern only
  • A Caller block that holds the identity conditions, like When

Proposed Outcome

Proposed option: "A Caller value keyword, with named claims and -Claim for others", to be revisited and accepted before work starts.

Resource *
Require 'Only approved apps write resources' {
    Caller AppId | Must -BeIn (Param AllowedClientAppIds)
}
Effect Deny
  • Caller Type, Caller AppId and Caller ObjectId emit [tryGet(requestContext().identity, '<claim>')] with the claim's name.
  • Caller AuthContext is a list, [split(tryGet(requestContext().identity, 'acrs'), ',')], tested with Must -Contain 'p1'.
  • Caller -Claim '<name>' covers other claims.
  • It works in Require and When, like ResourceGroupTag (ADR-0025).
  • Questions to settle before accepting:
  • Missing claims. Should a missing claim be a violation by default, as for a strict field, with -IfPresent to allow requests without it? Or the other way round? What does split do with a null acrs? That needs checking in a sandbox, like ADR-0004's truth table.
  • Effects. Error or warning for Audit, AuditIfNotExists, Manual and Append? Is denyAction really supported (Learn's list doesn't include it; the blog uses it)?
  • Compliance. Should every policy that uses Caller get a warning that its compliance state will be NotApplicable, or should that be documented only?
  • Values. Should Caller Type take only user and app?
  • Preview. Is the feature in preview? If so, warn, as for Modify on array elements (BYL3075).
  • Out of scope: resourceSelectors, overrides, enforcementMode and identity-based exemptions, which belong to assignments and exemptions, not definitions. Bylaw doesn't write those; EPAC does.

Consequences

  • Good, because identity rules read as plainly as resource rules, and their pitfalls are caught at build time.
  • Neutral, because the Arm form keeps working, and ConvertTo-Bylaw can turn it into Caller.
  • Bad, because the claim list may change, and the keyword has to keep up.

Confirmation

Unit and golden tests for each claim, the missing-claim behaviour and the effect checks. A sandbox run to confirm the missing-claim and split behaviour, recorded in this ADR.

Pros and Cons of the Options

Document the Arm pattern only

  • Good, because it needs no new language.
  • Bad, because the missing-claim behaviour stays implicit, and nothing warns about effects or compliance.

A Caller block that holds the identity conditions, like When

  • Good, because it groups identity conditions visibly.
  • Bad, because identity conditions belong in Require and When alongside resource conditions, as Learn's examples combine them, and a block of its own would need its own inversion rules.

More Information

  • ADR-0025 (value conditions), ADR-0003 and ADR-0004 (missing fields), ADR-0017 (DenyAction), ADR-0039 (ConvertTo-Bylaw)