Azure批处理作业:使用C#为用户订阅类型创建池

时间:2017-09-07 02:07:18

标签: azure-batch

我想使用c#为“用户订阅”创建Azure批处理作业池我没有看到这样的示例,我可以指定哪个Vnet来设置节点。我没有在CreatePool中看到任何设置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"));

用户订阅:创建池

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));

感谢

1 个答案:

答案 0 :(得分:1)

您需要CloudPool.NetworkConfiguration。这允许您指定SubnetId,它是包含vnet和子网名称的ARM ID。更多详情:https://docs.microsoft.com/en-us/rest/api/batchservice/add-a-pool-to-an-account#bk_netconf

但是,作为一个提醒,如果您在UserSubscription帐户,我相信您不能使用cloudServiceConfiguration。见https://docs.microsoft.com/en-us/rest/api/batchservice/add-a-pool-to-an-account。请改用virtualMachineConfiguration。