Skip to content

Commit 994d057

Browse files
authored
Update Azure CLI Cred (Azure#36553)
1 parent 9ee4f10 commit 994d057

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ AccessToken getTokenFromAzureCLIAuthentication(StringBuilder azCommand) {
532532
}
533533

534534
ProcessBuilder builder = new ProcessBuilder(starter, switcher, azCommand.toString());
535+
// Redirects stdin to dev null, helps to avoid messages sent in by the cmd process to upgrade etc.
536+
builder.redirectInput(ProcessBuilder.Redirect.from(IdentityUtil.NULL_FILE));
535537

536538
String workingDirectory = getSafeWorkingDirectory();
537539
if (workingDirectory != null) {
@@ -621,6 +623,8 @@ AccessToken getTokenFromAzureDeveloperCLIAuthentication(StringBuilder azdCommand
621623
}
622624

623625
ProcessBuilder builder = new ProcessBuilder(starter, switcher, azdCommand.toString());
626+
// Redirects stdin to dev null, helps to avoid messages sent in by the cmd process to upgrade etc.
627+
builder.redirectInput(ProcessBuilder.Redirect.from(IdentityUtil.NULL_FILE));
624628

625629
String workingDirectory = getSafeWorkingDirectory();
626630
if (workingDirectory != null) {

sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/util/IdentityUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.azure.identity.BrowserCustomizationOptions;
1212
import com.azure.identity.implementation.IdentityClientOptions;
1313

14+
import java.io.File;
1415
import java.util.Arrays;
1516
import java.util.Collections;
1617
import java.util.List;
@@ -22,6 +23,8 @@ public final class IdentityUtil {
2223
public static final String ALL_TENANTS = "*";
2324
public static final String DEFAULT_TENANT = "organizations";
2425

26+
public static final File NULL_FILE =
27+
new File((System.getProperty("os.name").startsWith("Windows") ? "NUL" : "/dev/null"));
2528

2629
private IdentityUtil() { }
2730
/**

0 commit comments

Comments
 (0)