1

I want to create a cloudpool with vnet,I typed codes:

1.use AzureAD

Task<string> tokenProvider() => GetAuthenticationTokenAsync();
using BatchClient batchClient = BatchClient.Open(new BatchTokenCredentials(_param.BatchAccountUrl, tokenProvider));

2.Create a pool

        CloudPool pool = batchClient.PoolOperations.CreatePool(
            poolId: _param.PoolId,
            targetDedicatedComputeNodes: _param.DedicatedNodeCount,
            virtualMachineSize: _param.PoolVMSize,
            virtualMachineConfiguration: vmConfiguration);

        pool.NetworkConfiguration = new()
        {
            SubnetId = $"/subscriptions/{_param.SubscriptionID}/resourceGroups/{_param.ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{_param.VnetName}/subnets/{_param.SubnetName}"
        };
        pool.TaskSlotsPerNode = 4;
        pool.ApplicationPackageReferences = new List<ApplicationPackageReference>
        {
            new ApplicationPackageReference
            {
                ApplicationId = _param.AppPackageId,
                Version = _param.AppPackageVersion
            }
        };

        pool.Commit();

When pool.Commit(); It return the "BadRequst". but I commented these codes, it's works.

                pool.NetworkConfiguration = new()
                {
                    SubnetId = $"/subscriptions/{_param.SubscriptionID}/resourceGroups/{_param.ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{_param.VnetName}/subnets/{_param.SubnetName}"
                };

Why?

1 Answers1

0

The response will tell you what the issue is, so you should look at that for the reason.

Most likely, either the subscription Id of the virtual network does not match that of the Batch account, or your AAD Service Principal has insufficient access permission for the virtual network. Please read carefully the requirements for deploying a Batch pool in a virtual network.

fpark
  • 2,304
  • 2
  • 14
  • 21