Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ internal static TokenCredential CreateCredential(IConfiguration configuration)
return new WorkloadIdentityCredential(workloadIdentityOptions);
}

throw new ArgumentException("For workload identity, 'tenantId', 'clientId', and 'tokenFilePath' must be specified via environment variables or the configuration.");
throw new ArgumentException("For workload identity, 'tenantId', 'clientId', and 'tokenFilePath' must be specified via the configuration.");
}

if (string.Equals(credentialType, "managedidentityasfederatedidentity", StringComparison.OrdinalIgnoreCase))
Expand All @@ -189,7 +189,7 @@ internal static TokenCredential CreateCredential(IConfiguration configuration)
string.IsNullOrWhiteSpace(clientId) ||
string.IsNullOrWhiteSpace(azureCloud))
{
throw new ArgumentException("For managed identity as a federated identity credential, 'tenantId', 'clientId', 'azureCloud', and one of ['managedIdentityClientId', 'resourceId', 'objectId'] must be specified via environment variables or the configuration.");
throw new ArgumentException("For managed identity as a federated identity credential, 'tenantId', 'clientId', 'azureCloud', and one of ['managedIdentityClientId', 'managedIdentityResourceId', 'managedIdentityObjectId'] must be specified via the configuration.");
}

if (!string.IsNullOrWhiteSpace(resourceId))
Expand Down Expand Up @@ -413,17 +413,20 @@ private static void AssertSingleManagedIdentityIdentifier(string clientId, strin
idCount += string.IsNullOrWhiteSpace(objectId) ? 0 : 1;

var validIdentifiers = isFederated
? "'clientId', 'managedIdentityClientId', 'managedIdentityResourceId', or 'managedIdentityObjectId'"
: "'managedIdentityClientId', 'managedIdentityResourceId', or 'managedIdentityObjectId'";
? "'managedIdentityClientId', 'managedIdentityResourceId', or 'managedIdentityObjectId'"
: "'clientId', 'managedIdentityClientId', 'managedIdentityResourceId', or 'managedIdentityObjectId'";

if (idCount > 1)
{
throw new ArgumentException($"Only one of [{validIdentifiers}] can be specified for managed identity.");
}

if (isFederated && idCount < 1)
if (idCount < 1)
{
throw new ArgumentException($"At least one of [{validIdentifiers}] must be specified for managed identity.");
var clientIdPart = isFederated ? "A clientId and exactly one" : "Exactly one";
var federatedPart = isFederated ? "federated " : " ";

throw new ArgumentException($"{clientIdPart} of [{validIdentifiers}] must be specified for {federatedPart}managed identity.");
}
}

Expand Down
Loading