migrate-apim: against CLI 1.0.0b34, provider and model creates are rejected, read-backs never match, and the Foundry endpoint 404s
メンテナーはふだん 1 日以内に返信
@santiagxf がすでに取り組んでいます。
2026年11月17日 から。
評価
この issue はまだ評価されていません。
説明
Summary
Against az aigateway 1.0.0b34 (default API version 2026-11-01), an end-to-end migrate-apim run can't finish, even for a small, clean APIM source:
applycan't create a model provider or a model: the resource provider rejects both withThe displayName property is required.- The provider and MCP read-backs compare against the 1.0.0b31 resource shape, so correct objects report
the object exists but does not match the desired state. - The planner copies APIM's
.../openaibackend URL as the Foundry provider endpoint. Every read-back saysverified, but inference returns 404. - An
authentication-managed-identitypolicy at API scope (the common APIM pattern) isn't recognized, so the plan has no identity step and no Foundry RBAC prerequisite.
The planner reports N items against CLI 1.0.0b31 (declared, not probed) (with --probe-cli: (probed)), while the installed CLI is 1.0.0b34.
Found while writing the migration section of lab 17 (PR #51). Every finding below was reproduced live with tools/migrate-apim at main 990fd3f. The plugin aigateway@azure v3.1.1 installed from the marketplace has an identical copy.
Environment
az aigateway1.0.0b34, Azure CLI 2.91.0, Python 3.14, macOS- Source: APIM BasicV2
@2025-09-01-previewin Sweden Central with a system-assigned identity, one Foundry account (gpt-5-mini2025-08-07, GlobalStandard), one Azure OpenAI model API withllm-token-limitandset-header, one product with one subscription, and one MCP passthrough API (https://learn.microsoft.com/api/mcp) - The source template is
labs/17-coding-agent-plugin/infra/apim-source.bicepin PR #51
Repro
TOOL=~/aigateway/tools/migrate-apim
PYTHONPATH=$TOOL python3 -m migrate_apim.cli collect --apim <apim> -g <rg> -o inventory.json
PYTHONPATH=$TOOL python3 -m migrate_apim.cli discover-tools --inventory inventory.json --allow-secret-use mcp:learn-mcp
PYTHONPATH=$TOOL python3 -m migrate_apim.cli plan --inventory inventory.json -o plan.json \
--target /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.ApiManagement/aigateways/<new-gateway>
# settle the 6 decisions, re-run plan, then for each phase:
PYTHONPATH=$TOOL python3 -m migrate_apim.cli apply --plan plan.json --inventory inventory.json --phase <phase> --execute
apply --status after the run:
steps: 8 in the plan, 2 failed, 6 verified
gateway complete (1 steps)
identity complete (1 steps)
providers stopped (1 steps) (rehearsed)
models complete (1 steps) <- only because the model was created by hand (workaround below)
aliases complete (1 steps)
toolServers stopped (1 steps) (rehearsed)
policies complete (1 steps)
keys complete (1 steps)
stuck:
failed: item:modelProvider/modelProvider-foundry-ai-endpoint -- foundry-ai-endpoint: ERROR: (ValidationError) ... The displayName property is required.
failed: item:mcp/learn-mcp/registration -- learn-mcp: the object exists but does not match the desired state
Findings
1. model-provider create is rejected: displayName is required
apply.py _provider_create (L869) builds az aigateway model-provider create ... --kind Foundry --foundry @<file> with no --display-name. With 1.0.0b34 the RP rejects it:
(ValidationError) One or more fields contain incorrect values:
Exception Details: (ValidationError) The displayName property is required.
The providers phase stops with exit 1: "Stopped in providers. The source APIM is untouched; the gateway is partially built."
Expected: pass --display-name (for example, the APIM backend name or its title).
2. model create is rejected the same way
_model_create (L882) also passes no --display-name, and the RP returns the same displayName property is required error once a provider exists.
3. The provider read-back expects the 1.0.0b31 shape
The comparison reads kind, foundry.endpoint as a string, and foundry.authentication. 1.0.0b34 (2026-11-01) returns:
{
"modelProviderType": "Foundry",
"displayName": "foundry-ai-endpoint",
"foundry": { "endpoint": { "url": "https://<acct>.cognitiveservices.azure.com/" }, "resourceIds": ["..."] },
"authentication": { "managedIdentity": { "resource": "https://cognitiveservices.azure.com/" } }
}
Even a correct provider reports "the object exists but does not match the desired state". Note the trailing / that the service adds to managedIdentity.resource.
4. The MCP read-back expects the 1.0.0b31 shape
The MCP server is created correctly (az aigateway mcp show and an initialize call through /default/toolservers/learn-mcp/mcp both work), but the read-back compares endpoints[].mcp.url and required: true. 1.0.0b34 returns endpoints[].mcp.endpoint.url, mode: "failClosed", plus id and gatewayEndpoints. The toolServers phase reports failed and stays stopped.
5. The planner uses APIM's /openai backend URL as the Foundry provider endpoint
plan.py _provider (L389) copies the backend URL https://<acct>.cognitiveservices.azure.com/openai into foundry.endpoint. The gateway needs the account root https://<acct>.cognitiveservices.azure.com/. With the /openai endpoint, every step reads back as verified, yet POST /default/models/openai/v1/chat/completions returns 404 Resource not found. This is the dangerous one: the run looks green and serves no traffic.
Expected: strip the API path suffix (/openai, /openai/v1, /models) for Foundry providers, or take the endpoint from the resolved Foundry account (properties.endpoint), which collect already reads.
6. An API-scoped authentication-managed-identity policy leaves provider auth undetermined
collect.py (around L1935-2000) reads provider auth from the backend's credentials.managedIdentity or from the backend-scoped effective policy only. The most common APIM pattern puts <authentication-managed-identity resource="https://cognitiveservices.azure.com" /> in the API policy. Then the provider shows auth=undetermined, and the plan has no identity.assign step and no prereq:foundry-rbac. The migrated gateway has no identity and no grant, and inference fails at runtime.
With credentials.managedIdentity on the backend instead, the inventory shows auth=managedIdentity and the plan includes both.
7. The planner proposes reuse-appinsights for an Azure Monitor logger
With only an azureMonitor logger (resourceId: null, no Application Insights), plan.py (L1025-1047) still proposes reuse-appinsights and adds the prerequisite "Enable the OTLP endpoint on the Application Insights resource APIM reports to". There is no such resource. The coding agent caught it during review ("The generated reuse recommendation is unsupported by the collected evidence"). Suggest proposing gateway-metrics-only or new-appinsights when no logger is applicationInsights.
8. --next-phase returns to a stopped phase
next_phase() (L547) returns the first incomplete phase, so after providers stops, --next-phase returns providers again, even when a later phase could run. The operator has to name every later phase with --phase. Consider a hint ("providers is stopped; later phases can run with --phase models") or a --skip option.
Verified fixes
In a patched copy of the tool (not proposed as a PR, so that the maintainers can choose the shape), the following made a full run finish with model 200 and MCP 200:
- Pass
--display-name <name>in_provider_createand_model_create. - Compare the 2026-11-01 provider shape:
modelProviderType,foundry.endpoint.url, top-levelauthentication.managedIdentity.resource(normalized trailing/). - Compare the 2026-11-01 MCP shape:
mcp.endpoint.url,mode, and ignoreidandgatewayEndpoints. - Normalize the Foundry endpoint to the account root in
plan.py.
Workarounds documented in lab 17
Until this is fixed, the lab tells learners to:
- After the identity phase, create the provider with the CLI's Foundry shortcut, which sets the root endpoint, the managed identity, and the Foundry User role:
az aigateway model-provider create -g <rg> --gateway-name <g> -n foundry-ai-endpoint --foundry-resource-id <account-id> - Create the model with the shortcut, then run
--phase models --execute, which reads it back as "already present with the desired state":
az aigateway model create -g <rg> --gateway-name <g> --provider-name foundry-ai-endpoint -n gpt-5-mini --deployment gpt-5-mini --foundry-resource-id <account-id> - Name each later phase with
--phase(aliases,toolServers,policies,keys), and check the MCP server withaz aigateway mcp showwhen toolServers reports "does not match". - Or skip
applyand have the coding agent write Bicep or Terraform from the settledplan.json. The lab ships a verified reference of both.
- 主要言語
- Python
- スター
- 18
- フォーク
- 9
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 22
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure/aigateway のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 53/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
migrate-apim: a policy element no rule answers for is dropped with no trace, and the ones with no expression in them vanish completely再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
migrate-apim: partialWhen conditions are declared in the schema and implemented in the planner, and nothing checks the two agree対応中かも @santiagxf が今日担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
Azure/aigateway の issue をすべて見る
似ている issue
-
area/network kind/documentation triage/needs-human
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
canonical/k8s-snap#3533 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: ops bug effort: small
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
juandresrodca/AdminForge#71 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
fossasia/eventyay-exhibition#465 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Deltakit/deltakit-circuit#28 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信