We do encounter the similar issue , we have a service principal with the Application.ReadWrite.OwnedBy and Cloud Application Administrator .
The replication delay maybe the issue , after completing the app registration, an immediate call of creating service principal often results in error When using this permission, the backing application of the service principal being created must in the local tenant due to hitting a cold replica, i think it is better to add a polling / retry function as a guard, making it less likely to hit the cold replica.
The Chain of Our Application
1. App registration : POST /applications
↓ replication delay
2. Create Service Principal : POST /servicePrincipals ← [Guard 1: waitForOwnership polls owners endpoint]
↓ replication delay
3 . Create Federated Credentials: POST /applications/{id}/federatedIdentityCredentials ← [Guard 2: retry loop on 404]
I am not sure but after setting Application.ReadWrite.All slightly help to resolve this issue but again this is not ideal due to the security issue of write all.
Problem of the cold replica (Not too sure if i am correct)
Problem 1 — SP creation fails:
POST /applications writes to Region A. Azure AD auto-adds the backend SP as owner of that app, but POST /servicePrincipals lands on Region B (cold replica). Region B sees: "you're trying to create an SP for an app you don't own" → rejected under OwnedBy.
→ waitForOwnership polls GET /applications/{id}/owners until Region B catches up.
Problem 2 — Federated credential creation fails:
Even after ownership is confirmed, POST /applications/{id}/federatedIdentityCredentials can land on Region C — a completely different cold replica that hasn't received the app object at all yet → 404 Request_ResourceNotFound.
→ Retry loop retries until Region C catches up.