Skip to content

[BUG] BatchClient.JobOperations.CreateJob returns invalid  #38772

Open
@azure-cow-9000

Description

@azure-cow-9000

Library name and version

Microsoft.Azure.Batch version 16.0.0

Describe the bug

  • In portal, I can create a job under the Azure Batch account with a GUID name (satisfies naming rules in documentation)
  • When using BatchClient.JobOperations.CreateJob, I receive an exception hinting that the name is invalid.

Expected behavior

Expect to create a job with a valid name.

I have tried a GUID string and a simple alpha string.

Actual behavior

System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

Creating job [751fd55e-943e-43fb-9e35-7cde3cc607e8]...
[12:46:36 ERR] Task creation or batch process failed!
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at Microsoft.Azure.Batch.Protocol.BatchSharedKeyCredential.ProcessHttpRequestAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken)
   at Microsoft.Azure.Batch.Protocol.JobOperations.AddWithHttpMessagesAsync(JobAddParameter job, JobAddOptions jobAddOptions, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.Batch.Protocol.BatchRequestBase`2.ExecuteRequestWithCancellationAsync(Func`2 func)
   at Microsoft.Azure.Batch.Protocol.BatchRequestBase`2.ExecuteRequestAsync()
   at Microsoft.Azure.Batch.Protocol.BatchRequestBase`2.ExecuteRequestAsync()
   at Microsoft.Azure.Batch.ProtocolLayer.ProcessAndExecuteBatchRequest[TResponse](IBatchRequest`1 request, BehaviorManager bhMgr)
   at Microsoft.Azure.Batch.CloudJob.CommitAsync(IEnumerable`1 additionalBehaviors, CancellationToken cancellationToken)...

Reproduction Steps

Run the following code against a valid batch account. This method was based off of a method in this sample project.

        public async Task<string> CreateJobAsync(BatchClient batchClient, string appPackageId, string poolId)
        {
            // this can't exceed 64 characters.. which means we can't do poolId_appId_GUID....   
            //var jobId = Guid.NewGuid().ToString(); // using this throws an error... 
            //var cleanedId =jobId.Replace("-", ""); // this doesn't work and gives invalid job ID error too... 
            var onlyAlphaCharJobId = "ifThisWorksIWillBeAngry"; // This still throws an exception
            Console.WriteLine("Creating job [{0}]...", onlyAlphaCharJobId);

            CloudJob job = batchClient.JobOperations.CreateJob(
                onlyAlphaCharJobId, 
                new PoolInformation { PoolId = poolId }
                );
            
            await job.CommitAsync();

            return onlyAlphaCharJobId;
        }

Environment

Azure pkg version

Microsoft.Azure.Batch version 16.0.0

dotnet --info ouput

.NET SDK:
Version: 7.0.400
Commit: 73bf45718d

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.400\

Host:
Version: 7.0.10
Architecture: x64
Commit: a6dbb800a4

Metadata

Metadata

Assignees

No one assigned

    Labels

    BatchClientThis issue points to a problem in the data-plane of the library.Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions