使用 Azure 门户创建 Batch 帐户Create a Batch account with the Azure portal

了解如何在 Azure 门户中创建 Azure Batch 帐户,以及如何选择适合计算方案的帐户属性。Learn how to create an Azure Batch account in the Azure portal, and choose the account properties that fit your compute scenario. 了解在何处查找重要的帐户属性,例如访问密钥和帐户 URL。Learn where to find important account properties like access keys and account URLs.

有关批处理帐户和方案的背景,请参阅功能概述For background about Batch accounts and scenarios, see the feature overview.

创建批处理帐户Create a Batch account

Note

创建 Batch 帐户时,可在两种“池分配”模式间进行选择:“用户订阅”和“Batch 服务”。When creating a Batch account, you can choose between two pool allocation modes: user subscription and Batch service. 在大部分情况下,应使用默认的 Batch 服务模式,使用此模式时,池在 Azure 托管的订阅中以幕后方式分配。For most cases, you should use the default Batch service mode, in which pools are allocated behind the scenes in Azure-managed subscriptions. 在备用的“用户订阅”模式下,会在创建池后直接在订阅中创建 Batch VM 和其他资源。In the alternative user subscription mode, Batch VMs and other resources are created directly in your subscription when a pool is created. 如果想要使用 Azure 虚拟机预留实例创建 Batch 池,则需要使用“用户订阅”模式。User subscription mode is required if you want to create Batch pools using Azure Reserved VM Instances. 若要在用户订阅模式下创建 Batch 帐户,还需将订阅注册到 Azure Batch 中,并将该帐户与 Azure Key Vault 相关联。To create a Batch account in user subscription mode, you must also register your subscription with Azure Batch, and associate the account with an Azure Key Vault.

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 选择“创建资源” > “计算” > “Batch 服务”。Select Create a resource > Compute > Batch Service.

    市场中的批处理

  3. 输入“新 Batch 帐户”设置。Enter New Batch account settings. 查看以下详细信息。See the following details.

    创建批处理帐户

    a.a. 订阅:要在其中创建 Batch 帐户的订阅。Subscription: The subscription in which to create the Batch account. 如果只有一个订阅,则默认选择此项。If you have only one subscription, it is selected by default.

    b.b. 资源组:为新 Batch 帐户选择现有的资源组,或选择创建一个新组。Resource group: Select an existing resource group for your new Batch account, or optionally create a new one.

    c.c. 帐户名称:所选名称必须在创建帐户的 Azure 区域中唯一(参见下面的“位置”)。Account name: The name you choose must be unique within the Azure region where the account is created (see Location below). 帐户名只能包含小写字符或数字,且长度必须为 3-24 个字符。The account name can contain only lowercase characters or numbers, and must be 3-24 characters in length.

    d.d. 位置:要在其中创建 Batch 帐户的 Azure 区域。Location: The Azure region in which to create the Batch account. 只有订阅和资源组支持的区域显示为选项。Only the regions supported by your subscription and resource group are displayed as options.

    e.e. 存储帐户:与 Batch 帐户关联的可选 Azure 存储帐户。Storage account: An optional Azure Storage account that you associate with your Batch account. 为获得最佳性能,建议使用常规用途 v2 存储帐户。A general-purpose v2 storage account is recommended for the best performance. 有关 Batch 中的所有存储帐户选项,请参阅 Batch 功能概述For all storage account options in Batch, see the Batch feature overview. 在门户中选择现有存储帐户,或者创建一个新帐户。In the portal, select an existing storage account, or create a new one.

    创建存储帐户

    f.f. 池分配模式:在“高级”设置选项卡中,可将池分配模式指定为“Batch 服务”或“用户订阅” 。Pool allocation mode: In the Advanced settings tab you can specify pool allocation mode as Batch service or User subscription. 对于大多数情况,请接受默认值“Batch 服务”。For most scenarios, accept the default Batch service.

    Batch 池分配模式

  4. 选择“创建”可创建帐户。Select Create to create the account.

查看 Batch 帐户属性View Batch account properties

创建帐户后,选择该帐户即可访问其设置和属性。Once the account has been created, select the account to access its settings and properties. 可以使用左侧菜单访问所有帐户设置和属性。You can access all account settings and properties by using the left menu.

Azure 门户中的 Batch 帐户页

  • Batch 帐户名、URL 和密钥:通过 Batch API 开发应用程序时,需要帐户 URL 和密钥才能访问 Batch 资源。Batch account name, URL, and keys: When you develop an application with the Batch APIs, you need an account URL and key to access your Batch resources. (Batch 还支持 Azure Active Directory 身份验证。)(Batch also supports Azure Active Directory authentication.)

    若要查看 Batch 帐户访问信息,请选择“密钥”。To view the Batch account access information, select Keys.

    Azure 门户中的 Batch 帐户密钥

  • 若要查看与 Batch 帐户关联的存储帐户的名称和密钥,请选择“存储帐户”。To view the name and keys of the storage account associated with your Batch account, select Storage account.

  • 若要查看适用于 Batch 帐户的资源配额,请选择“配额”。To view the resource quotas that apply to the Batch account, select Quotas. 有关详细信息,请参阅 Batch 服务配额和限制For details, see Batch service quotas and limits.

用户订阅模式的其他配置Additional configuration for user subscription mode

如果选择在用户订阅模式下创建 Batch 帐户,请在创建帐户前执行以下附加步骤。If you choose to create a Batch account in user subscription mode, perform the following additional steps before creating the account.

允许 Azure Batch 访问订阅(一次性操作)Allow Azure Batch to access the subscription (one-time operation)

在用户订阅模式下创建第一个 Batch 帐户时,需将订阅注册到 Batch 中。When creating your first Batch account in user subscription mode, you need to register your subscription with Batch. (如果已执行过此操作,请跳至下一部分。)(If you previously did this, skip to the next section.)

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 选择“所有服务” > “订阅”,然后选择要用于 Batch 帐户的订阅。Select All services > Subscriptions, and select the subscription you want to use for the Batch account.

  3. 在“订阅”页中选择“资源提供程序”,然后搜索“Microsoft.Batch”。In the Subscription page, select Resource providers, and search for Microsoft.Batch. 查看 Microsoft.Batch 资源提供程序是否已在订阅中注册。Check that the Microsoft.Batch resource provider is registered in the subscription. 如果未注册,请选择“注册”链接。If it isn't registered, select the Register link.

    注册 Microsoft.Batch 提供程序

  4. 在“订阅”页上,选择“访问控制(IAM)” > “角色分配” > “添加角色分配”。In the Subscription page, select Access control (IAM) > Role assignments > Add role assignment.

    订阅访问控制

  5. 在“添加角色分配”页上,选择“参与者”角色,然后搜索 Batch API 。On the Add role assignment page, select the Contributor role, search for the Batch API. 搜索每一条字符串,直到找到此 API:Search for each of these strings until you find the API:

    1. MicrosoftAzureBatch。MicrosoftAzureBatch.
    2. Microsoft Azure Batch。Microsoft Azure Batch. 较新的 Azure AD 租户可能使用此名称。Newer Azure AD tenants may use this name.
    3. ddbf3205-c6bd-46ae-8127-60eb93363864 是此 Batch API 的 ID。ddbf3205-c6bd-46ae-8127-60eb93363864 is the ID for the Batch API.
  6. 找到此 Batch API 后,将其选中,然后选择“保存”。Once you find the Batch API, select it and select Save.

    添加批处理权限

创建密钥保管库Create a key vault

在“用户订阅”模式下,需要的 Azure 密钥保管库与要创建的批处理帐户属于同一资源组。In user subscription mode, an Azure key vault is required that belongs to the same resource group as the Batch account to be created. 请确保资源组所在的区域是提供批处理的区域,也是订阅所支持的区域。Make sure the resource group is in a region where Batch is available and which your subscription supports.

  1. Azure 门户中,选择“新建” > “安全性” > “密钥保管库”。In the Azure portal, select New > Security > Key Vault.

  2. 在“创建密钥保管库”页中,输入密钥保管库的名称,并在区域中创建需要用于 Batch 帐户的资源组。In the Create Key Vault page, enter a name for the key vault, and create a resource group in the region you want for your Batch account. 让其余设置保留默认值,然后选择“创建”。Leave the remaining settings at default values, then select Create.

在用户订阅模式下创建 Batch 帐户时,请使用密钥保管库的资源组。When creating the Batch account in user subscription mode, use the resource group for the key vault. 指定“用户订阅”作为池分配模式,选择密钥保管库,然后选中该框以授予 Azure Batch 对密钥保管库的访问权限。Specify User subscription as the pool allocation mode, select the key vault, and check the box to grant Azure Batch access to the key vault.

如果希望手动授予对密钥保管库的访问权限,请转到密钥保管库的“访问策略”部分,然后选择“添加访问策略”并搜索“Microsoft Azure Batch”。If you prefer to grant access to the key vault manually, go to the Access policies section of the key vault and select Add Access Policy and search for Microsoft Azure Batch. 选择后,你将需要使用下拉菜单配置“机密权限”。Once selected, you will need to configure the Secret permissions using the drop down menu. 必须至少授予 Azure Batch GetListSetDelete 权限。Azure Batch must be given a minimum of Get, List, Set, and Delete permissions.

Azure Batch 的机密权限

Note

确保在链接的密钥保管库资源的“访问策略”下选中“用于部署的 Azure 虚拟机”和“用于模板部署的 Azure 资源管理器”复选框。Ensure that the Azure Virtual Machines for deployment and Azure Resource Manager for template deployment check boxes are selected under Access policies for the linked Key Vault resource.

强制实施密钥保管库访问策略在 Azure 门户中创建 Batch 帐户时,这不是必需的。Mandatory Key Vault Access Policy This is not mandatory when creating a Batch account in the Azure portal. 此选项默认情况下已选中。The option is selected by default.

配置订阅配额Configure subscription quotas

默认情况下,不在用户订阅 Batch 帐户上设置核心配额。Core quotas are not set by default on user subscription Batch accounts. 核心配额必须手动设置,因为标准 Batch 核心配额不适用于用户订阅模式下的帐户。Core quotas must be set manually because standard Batch core quotas do not apply to accounts in user subscription mode.

  1. Azure 门户中选择用户订阅模式 Batch 帐户,以便显示其设置和属性。In the Azure portal, select your user subscription mode Batch account to display its settings and properties.

  2. 在左侧菜单中选择“配额”,以便查看和配置与 Batch 帐户相关联的核心配额。From the left menu, select Quotas to view and configure the core quotas associated with your Batch account.

有关用户订阅模式核心配额的详细信息,请参阅 Batch 服务的配额和限制Refer to the Batch service quotas and limits for more information on user subscription mode core quotas.

其他 Batch 帐户管理选项Other Batch account management options

除了使用 Azure 门户外,还可使用以下工具创建和管理 Batch 帐户:In addition to using the Azure portal, you can create and manage Batch accounts with tools including the following:

后续步骤Next steps

  • 请参阅批处理功能概述,详细了解处理服务的概念和功能。See the Batch feature overview to learn more about Batch service concepts and features. 本文讨论主要 Batch 资源(例如池、计算节点、作业和任务),并提供适用于大规模计算工作负荷的服务功能概述。The article discusses the primary Batch resources such as pools, compute nodes, jobs, and tasks, and provides an overview of the service's features for large-scale compute workloads.
  • 了解使用批处理 .NET 客户端库 或 Python 开发支持批处理的应用程序的基本概念。Learn the basics of developing a Batch-enabled application using the Batch .NET client library or Python. 这些快速入门介绍了使用 Batch 服务在多个计算节点上执行工作负荷的示例应用程序,并说明了如何使用 Azure 存储进行工作负荷文件暂存和检索。These quickstarts guide you through a sample application that uses the Batch service to execute a workload on multiple compute nodes, and includes using Azure Storage for workload file staging and retrieval.