跨多个可用区创建 Azure Batch 池

支持可用性区域的 Azure 区域最少具有三个单独的区域,每个都有其自己的独立电源、网络和冷却系统。 在使用虚拟机配置创建 Azure Batch 池时,可以选择跨可用性区域预配 Batch 池。 使用此可用区策略创建池,有助于保护 Batch 计算节点免受 Azure 数据中心级别故障的影响。

例如,可以在支持三个可用区的 Azure 区域中使用区域策略创建池。 如果一个可用性区域中的Azure数据中心发生基础结构故障,则 Batch 池在另外两个可用性区域中仍具有正常的节点,因此该池仍可用于任务计划。

区域性支持和其他要求

Batch 在支持可用性区域方面与 Azure 保持一致。 若要使用区域性选项,必须在受支持的 Azure 区域中创建池。

若要将 Batch 池分配到多个可用性区域,创建该池的 Azure 区域必须在多个可用性区域中支持所请求的 VM SKU。 可以通过调用资源 Sku 列表 API 并检查 resourceSku 的“locationInfo”字段对此进行验证。 请确保请求的 VM SKU 支持多个区域。

对于用户订阅模式 Batch 帐户,请确保你要在其中创建池的订阅对所请求的 VM SKU 没有区域套餐限制。 若要确认这一点,请调用资源 SKU 列表 API 并检查 ResourceSkuRestrictions。 如果存在区域限制,可以提交支持票证来删除区域限制。

另请注意,如果池已经启用了节点间通信并且使用支持 InfiniBand 的 VM SKU,则无法创建具有区域性策略的池。

创建跨可用性区域的 Batch 池

下面的示例演示如何跨可用性区域创建 Batch 池。

注意

使用可用区策略创建池时,Batch 服务会尝试将池分配到所选区域中的所有可用区;你不能指定在这些可用区之间的具体分配方式。

批处理管理客户端 .NET SDK

var credential = new DefaultAzureCredential();
ArmClient _armClient = new ArmClient(credential);

var batchAccountIdentifier = ResourceIdentifier.Parse("your-batch-account-resource-id");

BatchAccountResource batchAccount = _armClient.GetBatchAccountResource(batchAccountIdentifier);

var poolName = "pool2";
var imageReference = new BatchImageReference()
{
    Publisher = "canonical",
    Offer = "0001-com-ubuntu-server-jammy",
    Sku = "22_04-lts",
    Version = "latest"
};
string nodeAgentSku = "batch.node.ubuntu 22.04";

var batchAccountPoolData = new BatchAccountPoolData()
{
    VmSize = "Standard_DS1_v2",
    DeploymentConfiguration = new BatchDeploymentConfiguration()
    {
        VmConfiguration = new BatchVmConfiguration(imageReference, nodeAgentSku)
        {
            NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal,
        },
    },
    ScaleSettings = new BatchAccountPoolScaleSettings()
    {
        FixedScale = new BatchAccountFixedScaleSettings()
        {
            TargetDedicatedNodes = 5,
            ResizeTimeout = TimeSpan.FromMinutes(15),
        }
    },

};

ArmOperation<BatchAccountPoolResource> armOperation = batchAccount.GetBatchAccountPools().CreateOrUpdate(
    WaitUntil.Completed, poolName, batchAccountPoolData);
BatchAccountPoolResource pool = armOperation.Value;

批量 REST 应用程序编程接口 (API)

REST API URL

POST {batchURL}/pools?api-version=2021-01-01.13.0
client-request-id: 00000000-0000-0000-0000-000000000000

请求体

"pool": {
    "id": "pool2",
    "vmSize": "standard_a1",
    "virtualMachineConfiguration": {
        "imageReference": {
            "publisher": "Canonical",
            "offer": "UbuntuServer",
            "sku": "20.04-lts"
        },
        "nodePlacementConfiguration": {
            "policy": "Zonal"
        }
        "nodeAgentSKUId": "batch.node.ubuntu 20.04"
    },
    "resizeTimeout": "PT15M",
    "targetDedicatedNodes": 5,
    "targetLowPriorityNodes": 0,
    "maxTasksPerNode": 3,
    "enableAutoScale": false,
    "enableInterNodeCommunication": false
}

后续步骤