建立跨可用性區域的 Azure Batch 集區

支援可用性區域的 Azure 區域至少會有三個不同的區域,每個區域都有自己的獨立電源、網路和冷卻系統。 當您使用虛擬機器設定建立 Azure Batch 集區時,您可以選擇跨可用性區域佈建 Batch 集區。 使用此區域原則建立集區有助於保護您的 Batch 計算節點免於 Azure 資料中心層級的失敗。

例如,您可以在支援三個可用性區域的 Azure 區域中,使用區域性原則建立您的集區。 如果 Azure 資料中心在一個可用性區域發生基礎設施故障,你的批次池在另外兩個 可用性區域 仍有健康的節點,因此該池仍可用於任務排程。

區域支援和其他需求

在支援可用性區域上,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 服務會嘗試將你的集區配置到所選區域中的所有可用性區域;你無法指定這些可用性區域之間的特定配置方式。

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
}

下一步