Skip to content

Commit 0afa58e

Browse files
add troubleshooting guide for identity (#17734)
* add troubleshooting guide for identity Co-authored-by: Scott Addie <[email protected]>
1 parent a319c90 commit 0afa58e

16 files changed

+281
-25
lines changed

sdk/identity/identity/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
After multiple beta releases over the past year, we're proud to announce the general availability of version 2 of the `@azure/identity` package. This version includes the best parts of v1, plus several improvements.
66

7-
This changelog entry showcases the changes that have been made from version 1 of this package. See the [v1-to-v2 migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/migration-v1-v2.md) for details on how to upgrade your application to use the version 2 of `@azure/identity`.
7+
This changelog entry showcases the changes that have been made from version 1 of this package. See the [v1-to-v2 migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/migration-v1-v2.md) for details on how to upgrade your application to use the version 2 of `@azure/identity`. For information on troubleshooting the Identity package, see the [troubleshooting guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/Troubleshooting.md).
88

99
### Features Added
1010

@@ -68,6 +68,7 @@ A new method `authenticate()` is added to these credentials which is similar to
6868
- `authenticate()` might succeed and still return `undefined` if we're unable to pick just one account record from the cache. This might happen if the cache is being used by more than one credential, or if multiple users have authenticated using the same Client ID and Tenant ID. To ensure consistency on a program with many users, please keep track of the `AuthenticationRecord` and provide them in the constructors of the credentials on initialization.
6969

7070
Learn more via the below samples
71+
7172
- [Samples around controlling user interaction](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#control-user-interaction).
7273
- [Samples around persisting user authentication data](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#persist-user-authentication-data).
7374

sdk/identity/identity/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,13 @@ Credentials raise `AuthenticationError` when they fail to authenticate. This cla
283283

284284
### Logging
285285

286-
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
286+
Enabling logging may help uncover useful information about failures. To see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. You can read this environment variable from the *.env* file by explicitly specifying a file path:
287+
288+
```javascript
289+
require("dotenv").config({ path: ".env" });
290+
```
291+
292+
Alternatively, logging can be enabled at runtime by calling `setLogLevel` from the `@azure/logger` package:
287293

288294
```javascript
289295
import { setLogLevel } from "@azure/logger";

sdk/identity/identity/Troubleshooting.md

Lines changed: 246 additions & 1 deletion
Large diffs are not rendered by default.

sdk/identity/identity/src/credentials/authorizationCodeCredential.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { TokenCredentialOptions } from "../client/identityClient";
77
import { credentialLogger, formatError } from "../util/logging";
88

99
const BrowserNotSupportedError = new Error(
10-
"AuthorizationCodeCredential is not supported in the browser. InteractiveBrowserCredential is more appropriate for this use case."
10+
"AuthorizationCodeCredential is not supported in the browser. InteractiveBrowserCredential is more appropriate for this use case."
1111
);
1212
const logger = credentialLogger("AuthorizationCodeCredential");
1313

sdk/identity/identity/src/credentials/azureApplicationCredential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ export class AzureApplicationCredential extends ChainedTokenCredential {
6060
constructor(options?: AzureApplicationCredentialOptions) {
6161
super(...AzureApplicationCredentials.map((ctor) => new ctor(options)));
6262
this.UnavailableMessage =
63-
"ApplicationCredential => failed to retrieve a token from the included credentials";
63+
"ApplicationCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit https://aka.ms/azsdk/js/identity/applicationcredential/troubleshoot.";
6464
}
6565
}

sdk/identity/identity/src/credentials/azurePowerShellCredential.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export const powerShellErrors = {
6363
export const powerShellPublicErrorMessages = {
6464
login:
6565
"Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.",
66-
installed: `The 'Az.Account' module >= 2.2.0 is not installed. Install the Azure Az PowerShell module with: "Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force".`
66+
installed: `The 'Az.Account' module >= 2.2.0 is not installed. Install the Azure Az PowerShell module with: "Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force".`,
67+
troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`
6768
};
6869

6970
// PowerShell Azure User not logged in error check.
@@ -92,7 +93,7 @@ export class AzurePowerShellCredential implements TokenCredential {
9293
private tenantId?: string;
9394

9495
/**
95-
* Creates an instance of the {@link AzurePowershellCredential}.
96+
* Creates an instance of the {@link AzurePowerShellCredential}.
9697
*
9798
* To use this credential:
9899
* - Install the Azure Az PowerShell module with:
@@ -150,7 +151,7 @@ export class AzurePowerShellCredential implements TokenCredential {
150151
}
151152
}
152153

153-
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system.`);
154+
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
154155
}
155156

156157
/**
@@ -192,7 +193,9 @@ export class AzurePowerShellCredential implements TokenCredential {
192193
logger.getToken.info(formatError(scope, error));
193194
throw error;
194195
}
195-
const error = new CredentialUnavailableError(err);
196+
const error = new CredentialUnavailableError(
197+
`${err}. ${powerShellPublicErrorMessages.troubleshoot}`
198+
);
196199
logger.getToken.info(formatError(scope, error));
197200
throw error;
198201
}

sdk/identity/identity/src/credentials/clientCertificateCredential.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ export class ClientCertificateCredential implements TokenCredential {
9797
};
9898
if (!configuration || !(configuration.certificate || configuration.certificatePath)) {
9999
throw new Error(
100-
`${credentialName}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem.`
100+
`${credentialName}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`
101101
);
102102
}
103103
if (configuration.certificate && configuration.certificatePath) {
104104
throw new Error(
105-
`${credentialName}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden.`
105+
`${credentialName}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`
106106
);
107107
}
108108
this.msalFlow = new MsalClientCertificate({

sdk/identity/identity/src/credentials/clientSecretCredential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ClientSecretCredential implements TokenCredential {
4040
) {
4141
if (!tenantId || !clientId || !clientSecret) {
4242
throw new Error(
43-
"ClientSecretCredential: tenantId, clientId, and clientSecret are required parameters."
43+
"ClientSecretCredential: tenantId, clientId, and clientSecret are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot."
4444
);
4545
}
4646
this.msalFlow = new MsalClientSecret({

sdk/identity/identity/src/credentials/defaultAzureCredential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ export class DefaultAzureCredential extends ChainedTokenCredential {
9494
constructor(options?: DefaultAzureCredentialOptions) {
9595
super(...defaultCredentials.map((ctor) => new ctor(options)));
9696
this.UnavailableMessage =
97-
"DefaultAzureCredential => failed to retrieve a token from the included credentials";
97+
"DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.";
9898
}
9999
}

sdk/identity/identity/src/credentials/environmentCredential.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ export class EnvironmentCredential implements TokenCredential {
132132
return result;
133133
} catch (err) {
134134
const authenticationError = new AuthenticationError(400, {
135-
error: "EnvironmentCredential authentication failed.",
135+
error:
136+
"EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.",
136137
error_description: err.message
137138
.toString()
138139
.split("More details:")
@@ -143,7 +144,7 @@ export class EnvironmentCredential implements TokenCredential {
143144
}
144145
}
145146
throw new CredentialUnavailableError(
146-
"EnvironmentCredential is unavailable. No underlying credential could be used."
147+
"EnvironmentCredential is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot."
147148
);
148149
});
149150
}

0 commit comments

Comments
 (0)