Hi Panu Hällfors & thx for join me at Q&A platform,
I went through your previous thread as well, and I think you've already done enough troubleshooting to establish that this isn't simply an azd deployment problem.
The important distinction is that your hosted agent deploys successfully, but the Microsoft 365 autopilot blueprint publishing operation fails. You've reproduced the same 502 upstream_dependency_failed through both the Foundry UI and the direct REST API, across different samples and regions.
That makes a local CLI issue or a problem specific to your agent code pretty unlikely.
I also noticed from your earlier investigation that the agent appears in the Microsoft 365 admin center Registry, but the expected autopilot publishing and approval workflow doesn't complete. Registry synchronization and successful blueprint publishing are separate operations, so the Registry entry alone doesn't confirm that everything is provisioned correctly.
The unresolved Frontier enrollment and terms acceptance status is still worth checking. However, I wouldn't conclude that licensing is causing the 502. Your existing Copilot Business and Agent 365 licenses shouldn't be dismissed simply because you don't have E7, and the response doesn't identify a specific eligibility failure.
At this point, the most useful next step is a backend trace of the Microsoft 365 publishing request, not another redeployment. Ur earlier REST request returned upstream_dependency_failed with request ID 7f715b8302179e291627d107f7f90e3d, using API version 2025-11-15-preview.
I'd ask the support engineer to correlate that request with the Foundry publishing service and its Microsoft 365 / Agent 365 dependencies, identify the exact operation that failed, and verify whether the tenant's autopilot enrollment and blueprint provisioning are complete. It's important to determine whether the 502 is masking an underlying tenant provisioning or authorization error, or whether an actual upstream service operation is failing. We can't reliably distinguish those possibilities from the public API response alone. Given that Microsoft Support specifically requested this new Q&A thread, I'd ask them to link it to your existing ticket and route the investigation to the Foundry Agent Service / Microsoft 365 Agent 365 publishing engineering team.
I wouldn't keep recreating Foundry resources or switching regions. You've already demonstrated that those changes don't resolve the failure. The remaining question is which backend dependency returns the failure, and that requires Microsoft-side telemetry. The existing request ID should provide a starting point for that investigation.
rgds,
Alex
p.s. if my answer is help - pls mark it as an answer