Azure Batch Job: Creating Pool for User Subscription type using C#

532 views Asked by At

I would like to create Azure Batch job pool using c# for "User Subscription" I do not see an example for this where I can specify which Vnet to setup the node. I not not see any option in CreatePool to set the VNet

pool = batchClient.PoolOperations.CreatePool(
                    poolId: poolId,
                    targetDedicatedComputeNodes: 3,                                             // 3 compute nodes
                    virtualMachineSize: "small",                                                // single-core, 1.75 GB memory, 225 GB disk
                    cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "4"));

User Subscription: Create Pool

ImageReference imgRef = new ImageReference(offer: "WindowsServer",
                    publisher: "MicrosoftWindowsServer", sku: "2012-R2-Datacenter");
                String nodeAgentSkuId = "batch.node.windows amd64";
                pool = batchClient.PoolOperations.CreatePool(
                    poolId: poolId,
                    targetDedicatedComputeNodes: 3,                                             // 3 compute nodes
                    virtualMachineSize: "small",                                                // single-core, 1.75 GB memory, 225 GB disk
                    virtualMachineConfiguration: new VirtualMachineConfiguration(imgRef, nodeAgentSkuId));

thanks

1

There are 1 answers

1
itowlson On

You need CloudPool.NetworkConfiguration. This allows you to specify a SubnetId which is an ARM ID that includes the vnet and subnet names. More details here: https://learn.microsoft.com/en-us/rest/api/batchservice/add-a-pool-to-an-account#bk_netconf

However, as a heads up, if you are in a UserSubscription account, I believe you can't use cloudServiceConfiguration. See https://learn.microsoft.com/en-us/rest/api/batchservice/add-a-pool-to-an-account. Use virtualMachineConfiguration instead.