From 638988854d9b4fa44779ce472141ffcafda4f495 Mon Sep 17 00:00:00 2001 From: Karishma Ghiya Date: Mon, 11 Oct 2021 10:46:38 -0700 Subject: [PATCH] update readme and triubleshooting --- sdk/identity/identity/README.md | 8 +++++++- sdk/identity/identity/Troubleshooting.md | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sdk/identity/identity/README.md b/sdk/identity/identity/README.md index 37befbad84ee..9763c4748fd9 100644 --- a/sdk/identity/identity/README.md +++ b/sdk/identity/identity/README.md @@ -257,7 +257,13 @@ Credentials raise `AuthenticationError` when they fail to authenticate. This cla ### Logging -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`: +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`. You can read this environment variable from the .env by explicitly specifying a path for the file: + +```javascript +require("dotenv").config({ path: ".env" }); +``` + +Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: ```javascript import { setLogLevel } from "@azure/logger"; diff --git a/sdk/identity/identity/Troubleshooting.md b/sdk/identity/identity/Troubleshooting.md index 7eff0c5ef844..b65cfaf41b83 100644 --- a/sdk/identity/identity/Troubleshooting.md +++ b/sdk/identity/identity/Troubleshooting.md @@ -40,6 +40,18 @@ Please follow the configuration instructions in the `Credential Unvavailable` se | Azure CLI Credential | [Azure CLI Troubleshooting Guide](#troubleshooting-azure-cli-authentication-issues) | | Azure Powershell Credential | [Azure Powershell Troubleshooting Guide](#troubleshooting-azure-powershell-authentication-issues) | +## Logging + +To help diagnose any errors in credentials that encompass multiple credentials like `DefaultAzureCredential`, [enabling logging](https://github.com/azure-sdk/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md) will also help you get a better understanding. + +Consider a scenario where you have these environment variables set up either in your environment or .env file - `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` You authenticate using `DefaultAzureCredential` and enable logging. +You will see the following logging statements - + +``` +azure:identity:info EnvironmentCredential => Found the following environment variables: AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET +azure:identity:info EnvironmentCredential => Invoking ClientSecretCredential with tenant ID: 72f988bf-86f1-41af-91ab-2d7cd011db47, clientId: f850650c-1fcf-4489-b46f-71af2e30d360 and clientSecret: [REDACTED] +``` + ## Troubleshooting Application Credential Authentication Issues ### Credential Unavailable Error @@ -227,8 +239,9 @@ The `Azure Powershell Credential` utilizes the locally installed `Powershell` co #### Azure Az Moudle Not Installed. The `Azure Powershell Credential` failed to execute as Azure az module is not installed. -To use Azure Powershell credential, the Azure az module needs to be installed. Install the Azure Az PowerShell module with: -```ps +To use Azure Powershell credential, the Azure az module needs to be installed. Install the Azure Az PowerShell module with: + +````ps Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force to install it for your platform and then try running the credential again. @@ -246,7 +259,7 @@ In your local powershell window, run the following command to ensure that Azure ```pwsh Get-AzAccessToken -ResourceUrl "" -``` +```` In the event above command is not working properly, follow the instructions to resolve the Azure Powershell issue being faced and then try running the credential again.