Skip to content

Commit a98f12e

Browse files
authored
Add managed identity timeout to troubleshooting guide (Azure#21018)
1 parent f2beb36 commit a98f12e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sdk/azidentity/TROUBLESHOOTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ azlog.SetListener(func(event azlog.Event, s string) {
7676
azlog.SetEvents(azidentity.EventAuthentication)
7777
```
7878

79+
<a id="dac"></a>
7980
## Troubleshoot DefaultAzureCredential authentication issues
8081

8182
| Error |Description| Mitigation |
8283
|---|---|---|
8384
|"DefaultAzureCredential failed to acquire a token"|No credential in the `DefaultAzureCredential` chain provided a token|<ul><li>[Enable logging](#enable-and-configure-logging) to get further diagnostic information.</li><li>Consult the troubleshooting guide for underlying credential types for more information.</li><ul><li>[EnvironmentCredential](#troubleshoot-environmentcredential-authentication-issues)</li><li>[ManagedIdentityCredential](#troubleshoot-managedidentitycredential-authentication-issues)</li><li>[AzureCLICredential](#troubleshoot-azureclicredential-authentication-issues)</li></ul>|
8485
|Error from the client with a status code of 401 or 403|Authentication succeeded but the authorizing Azure service responded with a 401 (Unauthorized), or 403 (Forbidden) status code|<ul><li>[Enable logging](#enable-and-configure-logging) to determine which credential in the chain returned the authenticating token.</li><li>If an unexpected credential is returning a token, check application configuration such as environment variables.</li><li>Ensure the correct role is assigned to the authenticated identity. For example, a service specific role rather than the subscription Owner role.</li></ul>|
86+
|"managed identity timed out"|`DefaultAzureCredential` sets a short timeout on its first managed identity authentication attempt to prevent very long timeouts during local development when no managed identity is available. That timeout causes this error in production when an application requests a token before the hosting environment is ready to provide one.|Use [ManagedIdentityCredential](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#ManagedIdentityCredential) directly, at least in production. It doesn't set a timeout on its authentication attempts.|
8587

8688
## Troubleshoot EnvironmentCredential authentication issues
8789

sdk/azidentity/default_azure_credential.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (w *timeoutWrapper) GetToken(ctx context.Context, opts policy.TokenRequestO
185185
defer cancel()
186186
tk, err = w.mic.GetToken(c, opts)
187187
if isAuthFailedDueToContext(err) {
188-
err = newCredentialUnavailableError(credNameManagedIdentity, "managed identity timed out")
188+
err = newCredentialUnavailableError(credNameManagedIdentity, "managed identity timed out. See https://aka.ms/azsdk/go/identity/troubleshoot#dac for more information")
189189
} else {
190190
// some managed identity implementation is available, so don't apply the timeout to future calls
191191
w.timeout = 0

0 commit comments

Comments
 (0)