Lesstep
GitHub Actions・Azure・2026年11月4日に確認

GitHub Actions の OIDC で Azure に入れない:「AADSTS700213: No matching federated identity record found」

GitHub はジョブにトークンを渡し、Microsoft Entra ID は、アプリの登録かマネージド ID のフェデレーション資格情報から、subject がトークンの sub とまったく同じものを探しました。見つかりませんでした。AWS と違って Entra は受け取った subject を表示するので、同じ文字列の資格情報を作れば直ります。

見え方

Federated token details:
 issuer - https://token.actions.githubusercontent.com
 subject claim - repo:octo-org@123456/octo-repo@456789:environment:dev
 audience - api://AzureADTokenExchange
 job_workflow_ref - octo-org/octo-repo/.github/workflows/deploy.yml@refs/heads/main
...
AADSTS700213: No matching federated identity record found for presented assertion subject 'repo:octo-org@123456/octo-repo@456789:environment:dev'. Check your federated identity credential Subject, Audience and Issuer against the presented assertion.
Error: Login failed with Error: The process '/usr/bin/az' failed with exit code 1. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.

最後の行は、az login の失敗を azure/login が伝えているものです。そこにある auth-type はここでは関係なく、問題は subject です。azure/login はログインの前にトークンの中身を表示するので、subject はログに2回出ます。

ID があるのはどちら側か

エラーの subject と、資格情報の subject を見比べます:

az ad app federated-credential list --id APP-OBJECT-ID --query "[].{name:name,subject:subject}"

ユーザー割り当てのマネージド ID なら az identity federated-credential list --identity-name NAME --resource-group GROUP です。そのうえで:

ジョブを走らせずに、自分のリポジトリの接頭辞を見るには:

gh api repos/OWNER/REPO/actions/oidc/customization/sub

答えには use_immutable_subject と sub_claim_prefix があり、たとえば repo:octo-org@123456/octo-repo@456789 です。

資格情報を足す

Microsoft のガイド「Migrate GitHub Actions federated credentials to immutable subjects」から、アプリの登録の場合です。中身を credential.json に書きます:

{
  "name": "octo-repo-dev",
  "issuer": "https://token.actions.githubusercontent.com",
  "subject": "repo:octo-org@123456/octo-repo@456789:environment:dev",
  "audiences": ["api://AzureADTokenExchange"]
}
az ad app federated-credential create --id APP-OBJECT-ID --parameters ./credential.json

ユーザー割り当てのマネージド ID なら:

az identity federated-credential create --name octo-repo-dev \
  --identity-name NAME --resource-group GROUP \
  --issuer https://token.actions.githubusercontent.com \
  --subject 'repo:octo-org@123456/octo-repo@456789:environment:dev' \
  --audiences api://AzureADTokenExchange

リポジトリのあとの部分

ジョブがトークンを頼んでいない

id-token: write が無いとトークンが無く、AADSTS のコードも出ません。azure/login は「Failed to fetch federated token from GitHub. Please make sure to give write permissions to id-token in the workflow.」と記録し、「Login failed with Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable.」で失敗します。

permissions:
  id-token: write
  contents: read

ジョブに permissions: を書くと、そのジョブではワークフローの分が置き換わるので、そこにも id-token: write が要ります。フォークからのプルリクエストと再利用ワークフローには、別の制限があります:「Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable」。

見分け方

失敗したジョブを IntelliJ IDEA から見るなら

Pipeline Inbox for GitHub Actions Workflows は、Lesstep が作っている JetBrains IDE(2024.1 以降)のプラグインです。すべてのリポジトリの実行を、ジョブ・ステップと一緒に IDE のツールウィンドウに並べ、いまのブランチの実行はステータスバーに出ます。読むのは無料、失敗したジョブの再実行・キャンセル・ワークフローの実行・デプロイのレビューは Pro(月 US$1.50・30日の無料試用つき)です。

GitHub と GitHub Actions は GitHub, Inc. の商標、Microsoft Azure と Microsoft Entra は Microsoft Corporation の商標、IntelliJ IDEA は JetBrains s.r.o. の商標です。このページは GitHub, Inc.・Microsoft・JetBrains のいずれとも提携しておらず、承認も受けていません。

ほかに:GitHub Actions の OIDC で AWS に入れない · 「Waiting」でレビューを待つ実行の承認 · npm publish の「ENEEDAUTH」 · IntelliJ IDEA で使える GitHub Actions のプラグインの比較 · English