创建具有指定公共 IP 地址的 Azure Batch 池Create an Azure Batch pool with specified public IP addresses

创建 Azure Batch 池时,可以在指定的 Azure 虚拟网络 (VNet) 的子网中预配该池When you create an Azure Batch pool, you can provision the pool in a subnet of an Azure virtual network (VNet) that you specify. 可以通过 Batch 创建的公共 IP 地址访问 Batch 池中的虚拟机。Virtual machines in the Batch pool are accessed through public IP addresses that are created by Batch. 这些公共 IP 地址在池的生存期内可能会发生变化,这意味着,如果未刷新 IP 地址,则网络设置可能会过时。These public IP addresses can change over the lifetime of the pool, which means that your network settings can become outdated if the IP addresses are not refreshed.

你可以创建用于池中的虚拟机的静态公共 IP 地址的列表。You can create a list of static public IP addresses to use with the virtual machines in your pool. 这样,你就可以控制公共 IP 地址的列表,确保它们不会意外更改。This allows you to control the list of public IP addresses and ensure that they won't change unexpectedly. 如果你在使用仅限特定 IP 地址访问的任何外部服务(如数据库),这会特别有用。This can be especially useful if you are working with any external service, such as a database, that restricts access to certain IP addresses.

先决条件Prerequisites

备注

Batch 自动在包含公共 IP 地址的资源组中分配其他网络资源。Batch automatically allocates additional networking resources in the resource group containing the public IP addresses. 通常情况下,每 100 个专用节点 Batch 会分配 1 个网络安全组 (NSG) 和 1 个负载均衡器。For each 100 dedicated nodes, Batch generally allocates one network security group (NSG) and one load balancer. 这些资源受订阅的资源配额限制。These resources are limited by the subscription's resource quotas. 当使用较大的池时,可能需要为一个或多个此类资源请求增加配额When using larger pools, you may need to request a quota increase for one or more of these resources.

公共 IP 地址要求Public IP address requirements

创建公共 IP 地址时,请注意以下要求:Keep in mind the following requirements when creating your public IP addresses:

  • 公共 IP 地址必须与用于创建池的 Batch 帐户位于同一订阅和区域中。The public IP addresses must be in the same subscription and region as the Batch account you use to create your pool.
  • “IP 地址分配”必须设置为“静态”。The IP address assignment must be set to Static.
  • “SKU”必须设置为“标准”。SKU must be set to Standard.
  • 必须指定 DNS 名称。A DNS name must be specified.
  • 公共 IP 地址必须仅用于虚拟机配置池。The public IP addresses must be used only for the virtual machine configuration pools. 其他资源不应使用这些 IP 地址,否则池可能会遇到分配失败的情况。No other resources should use these IP addresses, or the pool may experience allocation failures.
  • 不应有安全策略或资源锁限制用户对公共 IP 地址的访问。No security policies or resource locks should restrict a user's access to the public IP address.
  • 为池指定的公共 IP 地址的数量必须足够大,以便容纳为池指定的相应数目的 VM。The number of public IP addresses specified for the pool must be large enough to accommodate the number of VMs targeted for the pool. 该数目必须至少是池的 targetDedicatedNodes 和 targetLowPriorityNodes 属性之和。This must be at least the sum of the targetDedicatedNodes and targetLowPriorityNodes properties of the pool. 如果没有足够的 IP 地址,池会分配部分计算节点,并会发生重设大小错误。If there are not enough IP addresses, the pool partially allocates the compute nodes, and a resize error will occur. 目前,每 100 个 VM Batch 会使用一个公共 IP 地址。Currently, Batch uses one public IP address for every 100 VMs.
  • 请始终留出额外的公共 IP 地址以便进行缓冲。Always have an additional buffer of public IP addresses. 建议至少添加一个额外的公共 IP 地址,或者,额外添加的公共 IP 地址数是添加到池的公共 IP 地址总数的 10%,取两者中的较大者。We recommend adding at least one additional public IP address, or approximately 10% of the total public IP addresses that you add to a pool, whichever is greater. 此额外的缓冲将有助于 Batch 在纵向缩减时进行内部优化,并允许在纵向扩展或缩减失败后更快地进行纵向扩展。This additional buffer will help Batch with its internal optimization when scaling down, as well as allowing quicker scaling up after an unsuccessful scale up or scale down.
  • 创建池后,无法添加或更改池使用的公共 IP 地址的列表。Once the pool is created, you can't add or change the list of public IP addresses used by the Pool. 如果需要修改列表,则必须删除该池,然后重新创建它。If you need to modify the list, you must delete the pool and then recreate it.

创建具有公共 IP 地址的 Batch 池Create a Batch pool with public IP addresses

下面的示例展示了如何使用 Azure Batch 服务 REST API 来创建使用公共 IP 地址的池。The example below shows how to use the Azure Batch Service REST API to create a pool that uses public IP addresses.

Batch 服务 REST APIBatch Service REST API

REST API URIREST API URI

POST {batchURL}/pools?api-version=2020-03-01.11.0
client-request-id: 00000000-0000-0000-0000-000000000000

请求正文Request Body

"pool": {
      "id": "pool2",
      "vmSize": "standard_a1",
      "virtualMachineConfiguration": {
        "imageReference": {
          "publisher": "Canonical",
          "offer": "UbuntuServer",
          "sku": "16.04.0-LTS"
        },
        "nodeAgentSKUId": "batch.node.ubuntu 16.04"
      },
"networkConfiguration": {
          "subnetId": "/subscriptions/<subId>/resourceGroups/<rgId>/providers/Microsoft.Network/virtualNetworks/<vNetId>/subnets/<subnetId>",
          "publicIPAddressConfiguration": {
            "provision": "usermanaged",
            "ipAddressIds": [
              "/subscriptions/<subId>/resourceGroups/<rgId>/providers/Microsoft.Network/publicIPAddresses/<publicIpId>"
          ]
        },

       "resizeTimeout":"PT15M",
      "targetDedicatedNodes":5,
      "targetLowPriorityNodes":0,
      "maxTasksPerNode":3,
      "taskSchedulingPolicy": {
        "nodeFillType":"spread"
      }, 
      "enableAutoScale":false,
      "enableInterNodeCommunication":true,
      "metadata": [ {
        "name":"myproperty",
        "value":"myvalue"
      } ]
    }

后续步骤Next steps