From 65fa38bdb556963b8f4533b80307ebb912456a9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:15:29 +0000 Subject: [PATCH 1/3] Initial plan From 9cbe8931bd7281ea9298e4e1a061a6c85acc695a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:26:24 +0000 Subject: [PATCH 2/3] Add --no-prompt flag to AzureDeveloperCliCredential commands Co-authored-by: christothes <1279263+christothes@users.noreply.github.com> --- .../Credentials/AzureDeveloperCliCredential.cs | 4 ++-- .../tests/AzureDeveloperCliCredentialTests.cs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sdk/identity/Azure.Identity/src/Credentials/AzureDeveloperCliCredential.cs b/sdk/identity/Azure.Identity/src/Credentials/AzureDeveloperCliCredential.cs index cbc554372d40..23e4f413a141 100644 --- a/sdk/identity/Azure.Identity/src/Credentials/AzureDeveloperCliCredential.cs +++ b/sdk/identity/Azure.Identity/src/Credentials/AzureDeveloperCliCredential.cs @@ -207,8 +207,8 @@ private static void GetFileNameAndArguments(string[] scopes, string tenantId, ou string scopeArgs = string.Join(" ", scopes.Select(scope => $"--scope {scope}")); string command = tenantId switch { - null => $"azd auth token --output json {scopeArgs}", - _ => $"azd auth token --output json {scopeArgs} --tenant-id {tenantId}" + null => $"azd auth token --output json --no-prompt {scopeArgs}", + _ => $"azd auth token --output json --no-prompt {scopeArgs} --tenant-id {tenantId}" }; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) diff --git a/sdk/identity/Azure.Identity/tests/AzureDeveloperCliCredentialTests.cs b/sdk/identity/Azure.Identity/tests/AzureDeveloperCliCredentialTests.cs index 303ca5a7d000..1d8f46df5e4c 100644 --- a/sdk/identity/Azure.Identity/tests/AzureDeveloperCliCredentialTests.cs +++ b/sdk/identity/Azure.Identity/tests/AzureDeveloperCliCredentialTests.cs @@ -71,6 +71,22 @@ public async Task AuthenticateWithDeveloperCliCredential( } } + [Test] + public async Task AuthenticateWithDeveloperCliCredential_IncludesNoPromptFlag() + { + var context = new TokenRequestContext(new[] { Scope }); + var (expectedToken, expectedExpiresOn, processOutput) = CredentialTestHelpers.CreateTokenForAzureDeveloperCli(); + + var testProcess = new TestProcess { Output = processOutput }; + AzureDeveloperCliCredential credential = + InstrumentClient(new AzureDeveloperCliCredential(CredentialPipeline.GetInstance(null), new TestProcessService(testProcess, true))); + AccessToken actualToken = await credential.GetTokenAsync(context); + + Assert.AreEqual(expectedToken, actualToken.Token); + Assert.AreEqual(expectedExpiresOn, actualToken.ExpiresOn); + Assert.That(testProcess.StartInfo.Arguments, Does.Contain("--no-prompt")); + } + [Test] public void AuthenticateWithCliCredential_InvalidJsonOutput( [Values("", "{}", "{\"Some\": false}", "{\"token\": \"token\"}", "{\"expiresOn\" : \"1900-01-01T00:00:00Z\"}")] From 3fb23938dde2db120f9a1722867e30df681e114e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:04:33 +0000 Subject: [PATCH 3/3] Add changelog entry for AzureDeveloperCliCredential fix Co-authored-by: christothes <1279263+christothes@users.noreply.github.com> --- sdk/identity/Azure.Identity/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/identity/Azure.Identity/CHANGELOG.md b/sdk/identity/Azure.Identity/CHANGELOG.md index 2ee1a8dcc2f7..791f9a081219 100644 --- a/sdk/identity/Azure.Identity/CHANGELOG.md +++ b/sdk/identity/Azure.Identity/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fixed `AzureDeveloperCliCredential` hanging when the `AZD_DEBUG` environment variable is set by adding the `--no-prompt` flag to prevent interactive prompts ([#52005](https://github.com/Azure/azure-sdk-for-net/issues/52005)). + ### Other Changes ## 1.15.0 (2025-08-11)