Azure managed identity gets 401 from our API: token issued for the wrong audience
A Function App calling our internal API with its managed identity got 401 invalid_token on every request. The token was valid, but its aud claim was Azure Resource Manager. Then the second identity on the app picked the wrong client. How we decoded it and fixed both.