Skip to content

Commit 6d8cf4a

Browse files
Improve Azure Identity credential env var docs (Azure#47889)
* Improve DAC env var docs * Edit pass * Revert changes to EBN properties * Update DAC options XML docs * Improve XML docs for options classes * Update sdk/identity/Azure.Identity/src/Credentials/EnvironmentCredentialOptions.cs Co-authored-by: Christopher Scott <[email protected]> --------- Co-authored-by: Christopher Scott <[email protected]>
1 parent a915359 commit 6d8cf4a

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

sdk/identity/Azure.Identity/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Not all credentials require this configuration. Credentials that authenticate th
270270
271271
## Environment variables
272272

273-
[`DefaultAzureCredential`][ref_DefaultAzureCredential] and [`EnvironmentCredential`][ref_EnvironmentCredential] can be configured with environment variables. Each type of authentication requires values for specific variables.
273+
[`DefaultAzureCredential`][ref_DefaultAzureCredential] and [`EnvironmentCredential`][ref_EnvironmentCredential] can be configured with environment variables. Each type of authentication requires values for specific variables. Configuration is attempted in the order in which these environment variables are listed. For example, if values for a client secret and certificate are both present, the client secret is used by `EnvironmentCredential`.
274274

275275
### Service principal with secret
276276

@@ -299,13 +299,17 @@ Not all credentials require this configuration. Credentials that authenticate th
299299
|`AZURE_USERNAME`|a username (usually an email address)
300300
|`AZURE_PASSWORD`|that user's password
301301

302-
### Managed identity (`DefaultAzureCredential`)
302+
### Workload identity (`DefaultAzureCredential`)
303303

304304
|Variable name|Value
305305
|-|-
306-
|`AZURE_CLIENT_ID`|The client ID for the user-assigned managed identity. If defined, used as the default value for `ManagedIdentityClientId` in `DefaultAzureCredentialOptions`
306+
|`AZURE_CLIENT_ID`|The client ID of the application the workload identity will authenticate. If defined, used as the default value for `WorkloadIdentityClientId` in `DefaultAzureCredentialOptions`.
307+
308+
### Managed identity (`DefaultAzureCredential`)
307309

308-
Configuration is attempted in the order in which these environment variables are listed. For example, if values for a client secret and certificate are both present, the client secret is used.
310+
|Variable name|Value
311+
|-|-
312+
|`AZURE_CLIENT_ID`|The client ID for the user-assigned managed identity. If defined, used as the default value for `ManagedIdentityClientId` in `DefaultAzureCredentialOptions`.
309313

310314
## Continuous Access Evaluation
311315

sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredentialOptions.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public T Value
4848
/// <summary>
4949
/// The ID of the tenant to which the credential will authenticate by default. If not specified, the credential will authenticate to any requested tenant, and will default to the tenant to which the chosen authentication method was originally authenticated.
5050
/// </summary>
51+
/// <remarks>
52+
/// Defaults to the value of environment variable <c>AZURE_TENANT_ID</c>.
53+
/// </remarks>
5154
public string TenantId
5255
{
5356
get => _tenantId.Value;
@@ -101,7 +104,7 @@ public string InteractiveBrowserTenantId
101104
}
102105

103106
/// <summary>
104-
/// Specifies the tenant id of the preferred authentication account, to be retrieved from the shared token cache for single sign on authentication with
107+
/// Specifies the tenant ID of the preferred authentication account, to be retrieved from the shared token cache for single sign on authentication with
105108
/// development tools, in the case multiple accounts are found in the shared token.
106109
/// </summary>
107110
/// <remarks>
@@ -167,8 +170,10 @@ public string VisualStudioCodeTenantId
167170
/// Specifies tenants in addition to the specified <see cref="TenantId"/> for which the credential may acquire tokens.
168171
/// Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access.
169172
/// If no value is specified for <see cref="TenantId"/>, this option will have no effect on that authentication method, and the credential will acquire tokens for any requested tenant when using that method.
170-
/// This value can also be set by setting the environment variable AZURE_ADDITIONALLY_ALLOWED_TENANTS.
171173
/// </summary>
174+
/// <remarks>
175+
/// Defaults to the value of environment variable <c>AZURE_ADDITIONALLY_ALLOWED_TENANTS</c>.
176+
/// </remarks>
172177
public IList<string> AdditionallyAllowedTenants { get; internal set; } = EnvironmentVariables.AdditionallyAllowedTenants;
173178

174179
/// <summary>
@@ -177,25 +182,30 @@ public string VisualStudioCodeTenantId
177182
/// </summary>
178183
/// <remarks>
179184
/// If multiple accounts are found in the shared token cache and no value is specified, or the specified value matches no accounts in
180-
/// the cache the SharedTokenCacheCredential will not be used for authentication.
185+
/// the cache, the SharedTokenCacheCredential won't be used for authentication.
186+
/// Defaults to the value of environment variable <c>AZURE_USERNAME</c>.
181187
/// </remarks>
182188
public string SharedTokenCacheUsername { get; set; } = EnvironmentVariables.Username;
183189

184190
/// <summary>
185-
/// Specifies the client id of the selected credential
191+
/// Specifies the client ID of the selected credential.
186192
/// </summary>
187193
public string InteractiveBrowserCredentialClientId { get; set; }
188194

189195
/// <summary>
190-
/// Specifies the client id of the application the workload identity will authenticate.
196+
/// Specifies the client ID of the application the workload identity will authenticate.
191197
/// </summary>
198+
/// <remarks>
199+
/// Defaults to the value of environment variable <c>AZURE_CLIENT_ID</c>.
200+
/// </remarks>
192201
public string WorkloadIdentityClientId { get; set; } = EnvironmentVariables.ClientId;
193202

194203
/// <summary>
195204
/// Specifies the client ID of a user-assigned managed identity. If this value is configured, then <see cref="ManagedIdentityResourceId"/> should not be configured.
196205
/// </summary>
197206
/// <remarks>
198207
/// If neither the <see cref="ManagedIdentityClientId"/> nor the <see cref="ManagedIdentityResourceId"/> property is set, then a system-assigned managed identity is used.
208+
/// Defaults to the value of environment variable <c>AZURE_CLIENT_ID</c>.
199209
/// </remarks>
200210
public string ManagedIdentityClientId { get; set; } = EnvironmentVariables.ClientId;
201211

@@ -213,20 +223,20 @@ public string VisualStudioCodeTenantId
213223
public TimeSpan? CredentialProcessTimeout { get; set; } = TimeSpan.FromSeconds(30);
214224

215225
/// <summary>
216-
/// Specifies whether the <see cref="EnvironmentCredential"/> will be excluded from the authentication flow. Setting to true disables reading
226+
/// Specifies whether the <see cref="EnvironmentCredential"/> will be excluded from the authentication flow. Setting to <c>true</c> disables reading
217227
/// authentication details from the process' environment variables.
218228
/// </summary>
219229
public bool ExcludeEnvironmentCredential { get; set; }
220230

221231
/// <summary>
222-
/// Specifies whether the <see cref="WorkloadIdentityCredential"/> will be excluded from the authentication flow. Setting to true disables reading
232+
/// Specifies whether the <see cref="WorkloadIdentityCredential"/> will be excluded from the authentication flow. Setting to <c>true</c> disables reading
223233
/// authentication details from the process' environment variables.
224234
/// </summary>
225235
public bool ExcludeWorkloadIdentityCredential { get; set; }
226236

227237
/// <summary>
228238
/// Specifies whether the <see cref="ManagedIdentityCredential"/> will be excluded from the <see cref="DefaultAzureCredential"/> authentication flow.
229-
/// Setting to true disables authenticating with managed identity endpoints.
239+
/// Setting to <c>true</c> disables authenticating with managed identity endpoints.
230240
/// </summary>
231241
public bool ExcludeManagedIdentityCredential { get; set; }
232242

@@ -237,14 +247,14 @@ public string VisualStudioCodeTenantId
237247

238248
/// <summary>
239249
/// Specifies whether the <see cref="SharedTokenCacheCredential"/> will be excluded from the <see cref="DefaultAzureCredential"/> authentication flow.
240-
/// Setting to true disables single sign on authentication with development tools which write to the shared token cache.
250+
/// Setting to <c>true</c> disables single sign-on authentication with development tools which write to the shared token cache.
241251
/// The default is <c>true</c>.
242252
/// </summary>
243253
public bool ExcludeSharedTokenCacheCredential { get; set; } = true;
244254

245255
/// <summary>
246256
/// Specifies whether the <see cref="InteractiveBrowserCredential"/> will be excluded from the <see cref="DefaultAzureCredential"/> authentication flow.
247-
/// Setting to true disables launching the default system browser to authenticate in development environments.
257+
/// Setting to <c>true</c> disables launching the default system browser to authenticate in development environments.
248258
/// The default is <c>true</c>.
249259
/// </summary>
250260
public bool ExcludeInteractiveBrowserCredential { get; set; } = true;

sdk/identity/Azure.Identity/src/Credentials/EnvironmentCredentialOptions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class EnvironmentCredentialOptions : TokenCredentialOptions, ISupportsDis
4141
internal bool SendCertificateChain { get; set; } = EnvironmentVariables.ClientSendCertificateChain;
4242

4343
/// <summary>
44-
/// The username of the user account the credeential will authenticate. This value defaults to the value of the environment variable AZURE_USERNAME.
44+
/// The username of the user account the credential will authenticate. This value defaults to the value of the environment variable AZURE_USERNAME.
4545
/// </summary>
4646
internal string Username { get; set; } = EnvironmentVariables.Username;
4747

@@ -67,8 +67,10 @@ public class EnvironmentCredentialOptions : TokenCredentialOptions, ISupportsDis
6767
/// Specifies tenants in addition to the specified <see cref="TenantId"/> for which the credential may acquire tokens.
6868
/// Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access.
6969
/// If no value is specified for <see cref="TenantId"/>, this option will have no effect on that authentication method, and the credential will acquire tokens for any requested tenant when using that method.
70-
/// This value defaults to the value of the environment variable AZURE_ADDITIONALLY_ALLOWED_TENANTS.
7170
/// </summary>
71+
/// <remarks>
72+
/// Defaults to the value of environment variable <c>AZURE_ADDITIONALLY_ALLOWED_TENANTS</c>. Values can be a semi-colon delimited list of tenant IDs , or '*' to denote any tenant ID.
73+
/// </remarks>
7274
public IList<string> AdditionallyAllowedTenants { get; internal set; } = EnvironmentVariables.AdditionallyAllowedTenants;
7375
}
7476
}

sdk/identity/Azure.Identity/src/Credentials/UsernamePasswordCredentialOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Azure.Identity
1111
public class UsernamePasswordCredentialOptions : TokenCredentialOptions, ISupportsTokenCachePersistenceOptions, ISupportsDisableInstanceDiscovery, ISupportsAdditionallyAllowedTenants
1212
{
1313
/// <summary>
14-
/// Specifies the <see cref="TokenCachePersistenceOptions"/> to be used by the credential. If not options are specified, the token cache will not be persisted to disk.
14+
/// Specifies the <see cref="TokenCachePersistenceOptions"/> to be used by the credential. If no options are specified, the token cache will not be persisted to disk.
1515
/// </summary>
1616
public TokenCachePersistenceOptions TokenCachePersistenceOptions { get; set; }
1717

sdk/identity/Azure.Identity/src/Credentials/WorkloadIdentityCredentialOptions.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,27 @@ namespace Azure.Identity
1313
public class WorkloadIdentityCredentialOptions : TokenCredentialOptions, ISupportsDisableInstanceDiscovery, ISupportsAdditionallyAllowedTenants
1414
{
1515
/// <summary>
16-
/// The tenant ID of the service principal. Defaults to the value of the environment variable AZURE_TENANT_ID.
16+
/// The tenant ID of the service principal.
1717
/// </summary>
18+
/// <remarks>
19+
/// Defaults to the value of environment variable <c>AZURE_TENANT_ID</c>.
20+
/// </remarks>
1821
public string TenantId { get; set; } = EnvironmentVariables.TenantId;
1922

2023
/// <summary>
21-
/// The client (application) ID of the service principal. Defaults to the value of the environment variable AZURE_CLIENT_ID.
24+
/// The client (application) ID of the service principal.
2225
/// </summary>
26+
/// <remarks>
27+
/// Defaults to the value of environment variable <c>AZURE_CLIENT_ID</c>.
28+
/// </remarks>
2329
public string ClientId { get; set; } = EnvironmentVariables.ClientId;
2430

2531
/// <summary>
26-
/// The path to a file containing the workload identity token. Defaults to the value of the environment variable AZURE_FEDERATED_TOKEN_FILE.
32+
/// The path to a file containing the workload identity token.
2733
/// </summary>
34+
/// <remarks>
35+
/// Defaults to the value of environment variable <c>AZURE_FEDERATED_TOKEN_FILE</c>.
36+
/// </remarks>
2837
public string TokenFilePath { get; set; } = EnvironmentVariables.AzureFederatedTokenFile;
2938

3039
/// <inheritdoc />
@@ -34,8 +43,10 @@ public class WorkloadIdentityCredentialOptions : TokenCredentialOptions, ISuppor
3443
/// Specifies tenants in addition to the specified <see cref="TenantId"/> for which the credential may acquire tokens.
3544
/// Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the logged in account can access.
3645
/// If no value is specified for <see cref="TenantId"/>, this option will have no effect, and the credential will acquire tokens for any requested tenant.
37-
/// Defaults to the value of the environment variable AZURE_ADDITIONALLY_ALLOWED_TENANTS.
3846
/// </summary>
47+
/// <remarks>
48+
/// Defaults to the value of environment variable <c>AZURE_ADDITIONALLY_ALLOWED_TENANTS</c>.
49+
/// </remarks>
3950
public IList<string> AdditionallyAllowedTenants { get; internal set; } = EnvironmentVariables.AdditionallyAllowedTenants;
4051

4152
internal CredentialPipeline Pipeline { get; set; }

0 commit comments

Comments
 (0)