@@ -45,11 +45,40 @@ public async Task LoadIfNeededAsync(CredentialDescription credentialDescription,
45
45
string ? managedIdentityClientId ,
46
46
X509KeyStorageFlags x509KeyStorageFlags )
47
47
{
48
- Uri keyVaultUri = new Uri ( keyVaultUrl ) ;
49
- DefaultAzureCredentialOptions options = new ( )
48
+ Uri keyVaultUri = new ( keyVaultUrl ) ;
49
+
50
+ bool disableInteractiveCreds = false ;
51
+ var disableInteractiveCredsEnvVar = Environment . GetEnvironmentVariable ( "IDWEB_DISABLE_INTERACTIVE_AKV_CREDENTIALS" ) ;
52
+
53
+ if ( disableInteractiveCredsEnvVar != null && ( disableInteractiveCredsEnvVar == "1" || disableInteractiveCredsEnvVar . Equals ( "true" , StringComparison . OrdinalIgnoreCase ) ) )
54
+ {
55
+ disableInteractiveCreds = true ;
56
+ }
57
+
58
+ DefaultAzureCredentialOptions options ;
59
+
60
+ if ( disableInteractiveCreds )
61
+ {
62
+ options = new DefaultAzureCredentialOptions
63
+ {
64
+ ManagedIdentityClientId = managedIdentityClientId ,
65
+ ExcludeAzureCliCredential = true ,
66
+ ExcludeAzureDeveloperCliCredential = true ,
67
+ ExcludeAzurePowerShellCredential = true ,
68
+ ExcludeInteractiveBrowserCredential = true ,
69
+ ExcludeSharedTokenCacheCredential = true ,
70
+ ExcludeVisualStudioCodeCredential = true ,
71
+ ExcludeVisualStudioCredential = true
72
+ } ;
73
+ }
74
+ else
50
75
{
51
- ManagedIdentityClientId = managedIdentityClientId ,
52
- } ;
76
+ options = new DefaultAzureCredentialOptions
77
+ {
78
+ ManagedIdentityClientId = managedIdentityClientId ,
79
+ } ;
80
+ }
81
+
53
82
DefaultAzureCredential credential = new ( options ) ;
54
83
CertificateClient certificateClient = new ( keyVaultUri , credential ) ;
55
84
SecretClient secretClient = new ( keyVaultUri , credential ) ;
0 commit comments