@@ -41,12 +41,24 @@ public KeyVaultAccessToken(IServiceCollection dependencies, IDictionary<string,
4141 /// Gets the Azure Key Vault URI for which the access token will be requested.
4242 /// Example: https://anyvault.vault.azure.net/
4343 /// </summary>
44- protected string KeyVaultUri { get ; set ; }
44+ public string KeyVaultUri
45+ {
46+ get
47+ {
48+ return this . Parameters . GetValue < string > ( nameof ( this . KeyVaultUri ) ) ;
49+ }
50+ }
4551
4652 /// <summary>
4753 /// Gets the Azure tenant ID used to acquire an access token.
4854 /// </summary>
49- protected string TenantId { get ; set ; }
55+ protected string TenantId
56+ {
57+ get
58+ {
59+ return this . Parameters . GetValue < string > ( nameof ( this . TenantId ) ) ;
60+ }
61+ }
5062
5163 /// <summary>
5264 /// Gets or sets the full file path where the acquired access token will be written when file logging is enabled.
@@ -84,16 +96,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
8496 /// </summary>
8597 protected override async Task ExecuteAsync ( EventContext telemetryContext , CancellationToken cancellationToken )
8698 {
87- this . KeyVaultUri = this . Parameters . GetValue < string > ( nameof ( this . KeyVaultUri ) ) ;
8899 this . KeyVaultUri . ThrowIfNullOrWhiteSpace ( nameof ( this . KeyVaultUri ) ) ;
89-
90- string tenantId = this . Parameters . GetValue < string > ( nameof ( this . TenantId ) ) ;
91- if ( string . IsNullOrWhiteSpace ( tenantId ) )
92- {
93- EndpointUtility . TryParseMicrosoftEntraTenantIdReference ( new Uri ( this . KeyVaultUri ) , out tenantId ) ;
94- }
95-
96- tenantId . ThrowIfNullOrWhiteSpace ( nameof ( tenantId ) ) ;
100+ this . TenantId . ThrowIfNullOrWhiteSpace ( nameof ( this . TenantId ) ) ;
97101
98102 string accessToken = null ;
99103 if ( ! cancellationToken . IsCancellationRequested )
@@ -108,7 +112,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
108112 InteractiveBrowserCredential credential = new InteractiveBrowserCredential (
109113 new InteractiveBrowserCredentialOptions
110114 {
111- TenantId = tenantId
115+ TenantId = this . TenantId
112116 } ) ;
113117
114118 accessToken = await this . AcquireInteractiveTokenAsync ( credential , requestContext , cancellationToken ) ;
@@ -119,7 +123,7 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
119123 // the user with a code and URL to complete authentication from another device.
120124 DeviceCodeCredential credential = new DeviceCodeCredential ( new DeviceCodeCredentialOptions
121125 {
122- TenantId = tenantId ,
126+ TenantId = this . TenantId ,
123127 DeviceCodeCallback = ( codeInfo , token ) =>
124128 {
125129 Console . WriteLine ( string . Empty ) ;
0 commit comments