System.ArgumentNullException : Value cannot be null. (Parameter 'clientId')

Rupali Bhore 60 Reputation points
2025-07-31T05:31:38.55+00:00

My ADO pipeline give me error: at Test run task. System.ArgumentNullException : Value cannot be null. (Parameter 'clientId')

Stack trace

at Azure.Core.Argument.AssertNotNullT at Azure.Identity.ClientSecretCredential..ctor(String tenantId, String clientId, String clientSecret, TokenCredentialOptions options, CredentialPipeline pipeline, MsalConfidentialClient client) at Azure.Identity.ClientSecretCredential..ctor(String tenantId, String clientId, String clientSecret, ClientSecretCredentialOptions options) at ElementsOSIntegrationAPIAutomation.Services.CertificateService..ctor(IConfiguration configuration) in \src\Helpers\CertificateService.cs:line 29 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

User's image

I changed the secret but I updated the same in variable group. I also declared the same values in KV secrets and fetching the clientId from it.
User's image

I also tried to print those values in CLI, but as they are secret could not see them. Do I miss anything?
User's image

Azure DevOps
{count} votes

Answer accepted by question author
  1. Durga Reshma Malthi 11,590 Reputation points Microsoft External Staff Moderator
    2025-08-01T06:03:29.4233333+00:00

    Hi Rupali Bhore

    Can you update your VSTest@2 like this so that it will match configuration.GetValue<string>("ClientId") in CertificateService.cs

    - task: VSTest@2
      displayName: "Run Tests"
      env:
        ClientId: $(azureClientId)
        Secret: $(azureClientSecret)
        TenantId: $(tenantId)
    

    or alternatively you can update like this

    AzureClientId = configuration.GetValue<string>("azureClientId");
    AzureTenantId = configuration.GetValue<string>("tenantId");
    AzureSecret = configuration.GetValue<string>("azureClientSecret");
    

    Hope this helps!

    Please Let me know if you have any queries.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.