How to programatically set user password credentials when connecting to an HPC Scheduler

Nigel Findlater 96 Reputation points
2021-10-29T06:20:27.097+00:00

I am trying to schedule a job on an HPC Server 2019 cluster. I would like to do this without having to enter the password of the service account that I am using. Below is the code but the without commenting the line of code it fails to connect

string userName = GetKeyVaultSecret("ServiceAccount");
string password = GetKeyVaultSecret("ServiceAccountPassword");

using (IScheduler scheduler = new Scheduler())
{
    try
    {
            // Connect to the scheduler as another user
            Console.WriteLine("Connecting to {0} as {1}...", clusterName, userName);
            scheduler.SetCachedCredentials(userName,password); // If I comment this line I am prompted for a password and it connects
            scheduler.ConnectServiceAsClient(clusterName, () => userName);
    }
    catch (Exception e)
    {
        Console.Error.WriteLine("Could not connect to the scheduler: {0}", e.Message);
        if (e.InnerException != null) Console.WriteLine(e.InnerException.Message.ToString());
        return 1; 
    }
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Nigel Findlater 96 Reputation points
    2021-10-29T06:34:39.613+00:00

    The mistake was that I should not be setting the username and password here but when I submit the job

    	        scheduler.SubmitJob(job, @"domain\" + userName, password);
    

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.