@@ -230,16 +230,19 @@ func (c *managedIdentityClient) authenticate(ctx context.Context, id ManagedIDKi
230230 }
231231 return azcore.AccessToken {}, newCredentialUnavailableError (credNameManagedIdentity , msg )
232232 }
233- // because IMDS always responds with JSON, assume a non-JSON response is from something else, such
234- // as a proxy, and return credentialUnavailableError so DefaultAzureCredential continues iterating
233+ // Determine whether the response is from IMDS, a service whose managed identity API imitates IMDS such as Azure
234+ // Container Instances (ACI), or something other than a managed identity API. Assume a JSON response is from IMDS.
235+ // If the response is not JSON, check for a known ACI error message. If the response is neither JSON nor an ACI
236+ // error, assume it's from something like a proxy and return credentialUnavailableError so DefaultAzureCredential
237+ // continues to its next credential.
235238 b , err := azruntime .Payload (res )
236239 if err != nil {
237240 return azcore.AccessToken {}, newCredentialUnavailableError (credNameManagedIdentity , fmt .Sprintf ("failed to read IMDS probe response: %s" , err ))
238241 }
239- if ! json .Valid (b ) {
242+ if ! json .Valid (b ) && ! strings . HasPrefix ( string ( b ), "Required metadata header" ) {
240243 return azcore.AccessToken {}, newCredentialUnavailableError (credNameManagedIdentity , "unexpected response to IMDS probe" )
241244 }
242- // send normal token requests from now on because IMDS responded
245+ // send normal token requests from now on because IMDS, or something imitating it, responded
243246 c .probeIMDS = false
244247 }
245248
0 commit comments