在指定的帐户内创建新池。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}?api-version=2024-07-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
accountName
|
path |
True
|
string
|
Batch 帐户的名称。
正则表达式模式: ^[a-zA-Z0-9]+$
|
poolName
|
path |
True
|
string
|
池名称。 这在帐户中必须是唯一的。
正则表达式模式: ^[a-zA-Z0-9_-]+$
|
resourceGroupName
|
path |
True
|
string
|
包含 Batch 帐户的资源组的名称。
|
subscriptionId
|
path |
True
|
string
|
Azure 订阅 ID。 这是 GUID 格式的字符串(例如 000000000-0000-0000-00000-000000000000000)
|
api-version
|
query |
True
|
string
|
要用于 HTTP 请求的 API 版本。
|
名称 |
必需 |
类型 |
说明 |
If-Match
|
|
string
|
要更新的池的实体状态 (ETag) 版本。 仅当池已存在时,才能使用值“*”应用操作。 如果省略,将始终应用此操作。
|
If-None-Match
|
|
string
|
设置为“*”以允许创建新池,但要防止更新现有池。 将忽略其他值。
|
请求正文
名称 |
类型 |
说明 |
identity
|
BatchPoolIdentity
|
用于 Batch 池的标识类型。
用于 Batch 池的标识类型。
|
properties.applicationLicenses
|
string[]
|
Batch 服务将在池中的每个计算节点上可用的应用程序许可证列表。
应用程序许可证列表必须是可用 Batch 服务应用程序许可证的子集。 如果请求的许可证不受支持,则池创建将失败。
|
properties.applicationPackages
|
ApplicationPackageReference[]
|
要安装在池中每个计算节点上的应用程序包的列表。
对应用程序包引用的更改会影响所有加入池的新计算节点,但在重新启动或重新映像之前,不会影响池中已有的计算节点。 任何给定池上最多有 10 个应用程序包引用。
|
properties.certificates
|
CertificateReference[]
|
要安装在池中每个计算节点上的证书列表。
对于 Windows 计算节点,Batch 服务会将证书安装到指定的证书存储和位置。 对于 Linux 计算节点,证书存储在任务工作目录中的目录中,并向任务提供环境变量AZ_BATCH_CERTIFICATES_DIR以查询此位置。 对于可见性为“remoteUser”的证书,将在用户的主目录中(例如 /home/{user-name}/certs)中创建一个“certs”目录,并将证书置于该目录中。
警告:此属性已弃用,将在 2024 年 2 月之后删除。 请改用 Azure KeyVault 扩展。
|
properties.deploymentConfiguration
|
DeploymentConfiguration
|
此属性描述池节点将部署到的虚拟机。
|
properties.displayName
|
string
|
池的显示名称。
显示名称不一定是唯一的,可以包含最大长度为 1024 的任何 Unicode 字符。
|
properties.interNodeCommunication
|
InterNodeCommunicationState
|
池是否允许在节点之间直接通信。
这会对可分配给池的节点施加限制。 启用此值可以减少在池中分配请求的节点数的可能性。 如果未指定,则此值默认为“Disabled”。
|
properties.metadata
|
MetadataItem[]
|
与池关联的名称/值对列表作为元数据。
Batch 服务不向元数据分配任何含义;它仅用于使用用户代码。
|
properties.mountConfiguration
|
MountConfiguration[]
|
要安装在池中每个节点上的文件系统列表。
这支持 Azure 文件存储、NFS、CIFS/SMB 和 Blobfuse。
|
properties.networkConfiguration
|
NetworkConfiguration
|
池的网络配置。
池的网络配置。
|
properties.resourceTags
|
object
|
与池关联的用户指定的标记。
要与 Azure Batch 池关联的用户定义的标记。 指定后,这些标记将传播到与池关联的支持 Azure 资源。 仅当使用 poolAllocationMode 属性设置为“UserSubscription”创建的 Batch 帐户时,才能指定此属性。
|
properties.scaleSettings
|
ScaleSettings
|
配置池中节点数的设置。
定义池的所需大小。 这可以是指定所请求的目标DedicatedNode 的“fixedScale”,也可以是定义定期重新计算的公式的“autoScale”。 如果未指定此属性,则池将具有具有 0 个 targetDedicatedNodes 的固定缩放。
|
properties.startTask
|
StartTask
|
指定在联接池时在每个计算节点上运行的任务。
在 PATCH(更新)操作中,此属性可以设置为空对象,以从池中删除启动任务。
|
properties.targetNodeCommunicationMode
|
NodeCommunicationMode
|
池的所需节点通信模式。
如果省略,则默认值为 Default。
|
properties.taskSchedulingPolicy
|
TaskSchedulingPolicy
|
如何跨池中的计算节点分配任务。
如果未指定,则默认为分散。
|
properties.taskSlotsPerNode
|
integer
|
可用于在池中的单个计算节点上运行并发任务的任务槽数。
默认值为 1。 最大值是池的 vmSize 核心数或 256 的 4 倍。
|
properties.upgradePolicy
|
UpgradePolicy
|
池的升级策略。
描述升级策略 - 自动、手动或滚动。
|
properties.userAccounts
|
UserAccount[]
|
将在池中的每个节点上创建的用户帐户列表。
|
properties.vmSize
|
string
|
池中虚拟机的大小。 池中的所有 VM 大小相同。
有关可用 VM 大小的信息,请参阅虚拟机(Linux)(https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)或虚拟机(Windows)的大小(https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/)。 Batch 支持除STANDARD_A0和具有高级存储(STANDARD_GS、STANDARD_DS和STANDARD_DSV2系列)之外的所有 Azure VM 大小。
|
tags
|
object
|
资源的标记。
|
响应
名称 |
类型 |
说明 |
200 OK
|
Pool
|
操作成功。 响应包含池实体。
标头
ETag: string
|
Other Status Codes
|
CloudError
|
描述操作失败的原因的错误响应。
|
安全性
azure_auth
Microsoft Entra OAuth 2.0 身份验证代码流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
CreatePool - accelerated networking
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D1_V2",
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"enableAcceleratedNetworking": true
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.NetworkConfiguration;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.
* json
*/
/**
* Sample code: CreatePool - accelerated networking.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolAcceleratedNetworking(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D1_V2")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-datacenter-smalldisk").withVersion("latest"))
.withNodeAgentSkuId("batch.node.windows amd64")))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(1).withTargetLowPriorityNodes(0)))
.withNetworkConfiguration(new NetworkConfiguration().withSubnetId(
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123")
.withEnableAcceleratedNetworking(true))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_accelerated_networking.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-datacenter-smalldisk",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.windows amd64",
}
},
"networkConfiguration": {
"enableAcceleratedNetworking": True,
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}},
"vmSize": "STANDARD_D1_V2",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.json
func ExamplePoolClient_Create_createPoolAcceleratedNetworking() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-datacenter-smalldisk"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
},
},
NetworkConfiguration: &armbatch.NetworkConfiguration{
EnableAcceleratedNetworking: to.Ptr(true),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](1),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
VMSize: to.Ptr("STANDARD_D1_V2"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB46CB72A227E2\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateSteady),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-27T03:00:34.064Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-27T02:59:41.859Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](1),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// CurrentNodeCommunicationMode: to.Ptr(armbatch.NodeCommunicationModeClassic),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-datacenter-smalldisk"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-27T02:59:41.859Z"); return t}()),
// NetworkConfiguration: &armbatch.NetworkConfiguration{
// DynamicVNetAssignmentScope: to.Ptr(armbatch.DynamicVNetAssignmentScopeNone),
// EnableAcceleratedNetworking: to.Ptr(true),
// SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
// },
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-27T02:59:41.859Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-27T02:59:41.859Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](1),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](1),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D1_V2"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.json
*/
async function createPoolAcceleratedNetworking() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-datacenter-smalldisk",
version: "latest",
},
nodeAgentSkuId: "batch.node.windows amd64",
},
},
networkConfiguration: {
enableAcceleratedNetworking: true,
subnetId:
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 1, targetLowPriorityNodes: 0 },
},
vmSize: "STANDARD_D1_V2",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D1_V2",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64"),
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
},
},
NetworkConfiguration = new BatchNetworkConfiguration()
{
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
EnableAcceleratedNetworking = true,
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB46CB72A227E2"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB46CB72A227E2\"",
"properties": {
"lastModified": "2023-04-27T02:59:41.8592226Z",
"creationTime": "2023-04-27T02:59:41.8592226Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-04-27T02:59:41.8592226Z",
"allocationState": "Steady",
"allocationStateTransitionTime": "2023-04-27T03:00:34.0646502Z",
"vmSize": "STANDARD_D1_V2",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64"
}
},
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"dynamicVnetAssignmentScope": "none",
"enableAcceleratedNetworking": true
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 1,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-04-27T02:59:41.8592226Z"
},
"currentDedicatedNodes": 1,
"currentLowPriorityNodes": 0,
"currentNodeCommunicationMode": "Classic"
}
}
CreatePool - Custom Image
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.
* json
*/
/**
* Sample code: CreatePool - Custom Image.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolCustomImage(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(new DeploymentConfiguration().withVirtualMachineConfiguration(
new VirtualMachineConfiguration().withImageReference(new ImageReference().withId(
"/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_shared_image_gallery.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.json
func ExamplePoolClient_Create_createPoolCustomImage() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateSteady),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// TargetDedicatedNodes: to.Ptr[int32](0),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.json
*/
async function createPoolCustomImage() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
id: "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
}, "batch.node.ubuntu 18.04"),
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Steady",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 0,
"targetLowPriorityNodes": 0
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
CreatePool - Full VirtualMachineConfiguration
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter-SmallDisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
"licenseType": "Windows_Server",
"dataDisks": [
{
"lun": 0,
"caching": "ReadWrite",
"diskSizeGB": 30,
"storageAccountType": "Premium_LRS"
},
{
"lun": 1,
"caching": "None",
"diskSizeGB": 200,
"storageAccountType": "Standard_LRS"
}
],
"diskEncryptionConfiguration": {
"targets": [
"OsDisk",
"TemporaryDisk"
]
},
"nodePlacementConfiguration": {
"policy": "Zonal"
},
"osDisk": {
"ephemeralOSDiskSettings": {
"placement": "CacheDisk"
}
}
}
},
"networkConfiguration": {
"endpointConfiguration": {
"inboundNatPools": [
{
"name": "testnat",
"protocol": "TCP",
"backendPort": 12001,
"frontendPortRangeStart": 15000,
"frontendPortRangeEnd": 15100,
"networkSecurityGroupRules": [
{
"access": "Allow",
"sourceAddressPrefix": "192.100.12.45",
"priority": 150,
"sourcePortRanges": [
"1",
"2"
]
},
{
"access": "Deny",
"sourceAddressPrefix": "*",
"priority": 3500,
"sourcePortRanges": [
"*"
]
}
]
}
]
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
}
}
}
import com.azure.resourcemanager.batch.models.AutoScaleSettings;
import com.azure.resourcemanager.batch.models.CachingType;
import com.azure.resourcemanager.batch.models.DataDisk;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.DiffDiskPlacement;
import com.azure.resourcemanager.batch.models.DiffDiskSettings;
import com.azure.resourcemanager.batch.models.DiskEncryptionConfiguration;
import com.azure.resourcemanager.batch.models.DiskEncryptionTarget;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.InboundEndpointProtocol;
import com.azure.resourcemanager.batch.models.InboundNatPool;
import com.azure.resourcemanager.batch.models.NetworkConfiguration;
import com.azure.resourcemanager.batch.models.NetworkSecurityGroupRule;
import com.azure.resourcemanager.batch.models.NetworkSecurityGroupRuleAccess;
import com.azure.resourcemanager.batch.models.NodePlacementConfiguration;
import com.azure.resourcemanager.batch.models.NodePlacementPolicyType;
import com.azure.resourcemanager.batch.models.OSDisk;
import com.azure.resourcemanager.batch.models.PoolEndpointConfiguration;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.StorageAccountType;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import com.azure.resourcemanager.batch.models.WindowsConfiguration;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/
* PoolCreate_VirtualMachineConfiguration.json
*/
/**
* Sample code: CreatePool - Full VirtualMachineConfiguration.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolFullVirtualMachineConfiguration(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(
new DeploymentConfiguration()
.withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2016-Datacenter-SmallDisk").withVersion("latest"))
.withNodeAgentSkuId("batch.node.windows amd64")
.withWindowsConfiguration(new WindowsConfiguration().withEnableAutomaticUpdates(false))
.withDataDisks(Arrays.asList(
new DataDisk().withLun(0).withCaching(CachingType.READ_WRITE).withDiskSizeGB(30)
.withStorageAccountType(StorageAccountType.PREMIUM_LRS),
new DataDisk().withLun(1).withCaching(CachingType.NONE).withDiskSizeGB(200)
.withStorageAccountType(StorageAccountType.STANDARD_LRS)))
.withLicenseType("Windows_Server")
.withDiskEncryptionConfiguration(new DiskEncryptionConfiguration().withTargets(
Arrays.asList(DiskEncryptionTarget.OS_DISK, DiskEncryptionTarget.TEMPORARY_DISK)))
.withNodePlacementConfiguration(
new NodePlacementConfiguration().withPolicy(NodePlacementPolicyType.ZONAL))
.withOsDisk(new OSDisk().withEphemeralOSDiskSettings(
new DiffDiskSettings().withPlacement(DiffDiskPlacement.CACHE_DISK)))))
.withScaleSettings(
new ScaleSettings()
.withAutoScale(
new AutoScaleSettings().withFormula(
"$TargetDedicatedNodes=1").withEvaluationInterval(
Duration.parse("PT5M"))))
.withNetworkConfiguration(
new NetworkConfiguration()
.withEndpointConfiguration(new PoolEndpointConfiguration().withInboundNatPools(
Arrays.asList(new InboundNatPool().withName("testnat").withProtocol(InboundEndpointProtocol.TCP)
.withBackendPort(12001).withFrontendPortRangeStart(15000).withFrontendPortRangeEnd(15100)
.withNetworkSecurityGroupRules(Arrays.asList(new NetworkSecurityGroupRule()
.withPriority(150).withAccess(NetworkSecurityGroupRuleAccess.ALLOW)
.withSourceAddressPrefix("192.100.12.45").withSourcePortRanges(Arrays.asList("1", "2")),
new NetworkSecurityGroupRule().withPriority(3500)
.withAccess(NetworkSecurityGroupRuleAccess.DENY).withSourceAddressPrefix("*")
.withSourcePortRanges(Arrays.asList("*"))))))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_virtual_machine_configuration.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"dataDisks": [
{"caching": "ReadWrite", "diskSizeGB": 30, "lun": 0, "storageAccountType": "Premium_LRS"},
{"caching": "None", "diskSizeGB": 200, "lun": 1, "storageAccountType": "Standard_LRS"},
],
"diskEncryptionConfiguration": {"targets": ["OsDisk", "TemporaryDisk"]},
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter-SmallDisk",
"version": "latest",
},
"licenseType": "Windows_Server",
"nodeAgentSkuId": "batch.node.windows amd64",
"nodePlacementConfiguration": {"policy": "Zonal"},
"osDisk": {"ephemeralOSDiskSettings": {"placement": "CacheDisk"}},
"windowsConfiguration": {"enableAutomaticUpdates": False},
}
},
"networkConfiguration": {
"endpointConfiguration": {
"inboundNatPools": [
{
"backendPort": 12001,
"frontendPortRangeEnd": 15100,
"frontendPortRangeStart": 15000,
"name": "testnat",
"networkSecurityGroupRules": [
{
"access": "Allow",
"priority": 150,
"sourceAddressPrefix": "192.100.12.45",
"sourcePortRanges": ["1", "2"],
},
{
"access": "Deny",
"priority": 3500,
"sourceAddressPrefix": "*",
"sourcePortRanges": ["*"],
},
],
"protocol": "TCP",
}
]
}
},
"scaleSettings": {"autoScale": {"evaluationInterval": "PT5M", "formula": "$TargetDedicatedNodes=1"}},
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration.json
func ExamplePoolClient_Create_createPoolFullVirtualMachineConfiguration() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
DataDisks: []*armbatch.DataDisk{
{
Caching: to.Ptr(armbatch.CachingTypeReadWrite),
DiskSizeGB: to.Ptr[int32](30),
Lun: to.Ptr[int32](0),
StorageAccountType: to.Ptr(armbatch.StorageAccountTypePremiumLRS),
},
{
Caching: to.Ptr(armbatch.CachingTypeNone),
DiskSizeGB: to.Ptr[int32](200),
Lun: to.Ptr[int32](1),
StorageAccountType: to.Ptr(armbatch.StorageAccountTypeStandardLRS),
}},
DiskEncryptionConfiguration: &armbatch.DiskEncryptionConfiguration{
Targets: []*armbatch.DiskEncryptionTarget{
to.Ptr(armbatch.DiskEncryptionTargetOsDisk),
to.Ptr(armbatch.DiskEncryptionTargetTemporaryDisk)},
},
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2016-Datacenter-SmallDisk"),
Version: to.Ptr("latest"),
},
LicenseType: to.Ptr("Windows_Server"),
NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
NodePlacementConfiguration: &armbatch.NodePlacementConfiguration{
Policy: to.Ptr(armbatch.NodePlacementPolicyTypeZonal),
},
OSDisk: &armbatch.OSDisk{
EphemeralOSDiskSettings: &armbatch.DiffDiskSettings{
Placement: to.Ptr("CacheDisk"),
},
},
WindowsConfiguration: &armbatch.WindowsConfiguration{
EnableAutomaticUpdates: to.Ptr(false),
},
},
},
NetworkConfiguration: &armbatch.NetworkConfiguration{
EndpointConfiguration: &armbatch.PoolEndpointConfiguration{
InboundNatPools: []*armbatch.InboundNatPool{
{
Name: to.Ptr("testnat"),
BackendPort: to.Ptr[int32](12001),
FrontendPortRangeEnd: to.Ptr[int32](15100),
FrontendPortRangeStart: to.Ptr[int32](15000),
NetworkSecurityGroupRules: []*armbatch.NetworkSecurityGroupRule{
{
Access: to.Ptr(armbatch.NetworkSecurityGroupRuleAccessAllow),
Priority: to.Ptr[int32](150),
SourceAddressPrefix: to.Ptr("192.100.12.45"),
SourcePortRanges: []*string{
to.Ptr("1"),
to.Ptr("2")},
},
{
Access: to.Ptr(armbatch.NetworkSecurityGroupRuleAccessDeny),
Priority: to.Ptr[int32](3500),
SourceAddressPrefix: to.Ptr("*"),
SourcePortRanges: []*string{
to.Ptr("*")},
}},
Protocol: to.Ptr(armbatch.InboundEndpointProtocolTCP),
}},
},
},
ScaleSettings: &armbatch.ScaleSettings{
AutoScale: &armbatch.AutoScaleSettings{
EvaluationInterval: to.Ptr("PT5M"),
Formula: to.Ptr("$TargetDedicatedNodes=1"),
},
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// DataDisks: []*armbatch.DataDisk{
// {
// Caching: to.Ptr(armbatch.CachingTypeReadWrite),
// DiskSizeGB: to.Ptr[int32](30),
// Lun: to.Ptr[int32](0),
// StorageAccountType: to.Ptr(armbatch.StorageAccountTypePremiumLRS),
// },
// {
// Caching: to.Ptr(armbatch.CachingTypeNone),
// DiskSizeGB: to.Ptr[int32](200),
// Lun: to.Ptr[int32](1),
// StorageAccountType: to.Ptr(armbatch.StorageAccountTypeStandardLRS),
// }},
// DiskEncryptionConfiguration: &armbatch.DiskEncryptionConfiguration{
// Targets: []*armbatch.DiskEncryptionTarget{
// to.Ptr(armbatch.DiskEncryptionTargetOsDisk),
// to.Ptr(armbatch.DiskEncryptionTargetTemporaryDisk)},
// },
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2016-Datacenter-SmallDisk"),
// Version: to.Ptr("latest"),
// },
// LicenseType: to.Ptr("Windows_Server"),
// NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
// NodePlacementConfiguration: &armbatch.NodePlacementConfiguration{
// Policy: to.Ptr(armbatch.NodePlacementPolicyTypeZonal),
// },
// WindowsConfiguration: &armbatch.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(false),
// },
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// NetworkConfiguration: &armbatch.NetworkConfiguration{
// EndpointConfiguration: &armbatch.PoolEndpointConfiguration{
// InboundNatPools: []*armbatch.InboundNatPool{
// {
// Name: to.Ptr("testnat"),
// BackendPort: to.Ptr[int32](12001),
// FrontendPortRangeEnd: to.Ptr[int32](15100),
// FrontendPortRangeStart: to.Ptr[int32](15000),
// NetworkSecurityGroupRules: []*armbatch.NetworkSecurityGroupRule{
// {
// Access: to.Ptr(armbatch.NetworkSecurityGroupRuleAccessAllow),
// Priority: to.Ptr[int32](150),
// SourceAddressPrefix: to.Ptr("192.100.12.45"),
// SourcePortRanges: []*string{
// to.Ptr("1"),
// to.Ptr("2")},
// },
// {
// Access: to.Ptr(armbatch.NetworkSecurityGroupRuleAccessDeny),
// Priority: to.Ptr[int32](3500),
// SourceAddressPrefix: to.Ptr("*"),
// SourcePortRanges: []*string{
// to.Ptr("*")},
// }},
// Protocol: to.Ptr(armbatch.InboundEndpointProtocolTCP),
// }},
// },
// },
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// AutoScale: &armbatch.AutoScaleSettings{
// EvaluationInterval: to.Ptr("PT5M"),
// Formula: to.Ptr("$TargetDedicatedNodes=1"),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration.json
*/
async function createPoolFullVirtualMachineConfiguration() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
dataDisks: [
{
caching: "ReadWrite",
diskSizeGB: 30,
lun: 0,
storageAccountType: "Premium_LRS",
},
{
caching: "None",
diskSizeGB: 200,
lun: 1,
storageAccountType: "Standard_LRS",
},
],
diskEncryptionConfiguration: { targets: ["OsDisk", "TemporaryDisk"] },
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2016-Datacenter-SmallDisk",
version: "latest",
},
licenseType: "Windows_Server",
nodeAgentSkuId: "batch.node.windows amd64",
nodePlacementConfiguration: { policy: "Zonal" },
osDisk: { ephemeralOSDiskSettings: { placement: "CacheDisk" } },
windowsConfiguration: { enableAutomaticUpdates: false },
},
},
networkConfiguration: {
endpointConfiguration: {
inboundNatPools: [
{
name: "testnat",
backendPort: 12001,
frontendPortRangeEnd: 15100,
frontendPortRangeStart: 15000,
networkSecurityGroupRules: [
{
access: "Allow",
priority: 150,
sourceAddressPrefix: "192.100.12.45",
sourcePortRanges: ["1", "2"],
},
{
access: "Deny",
priority: 3500,
sourceAddressPrefix: "*",
sourcePortRanges: ["*"],
},
],
protocol: "TCP",
},
],
},
},
scaleSettings: {
autoScale: {
evaluationInterval: "PT5M",
formula: "$TargetDedicatedNodes=1",
},
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-Datacenter-SmallDisk",
Version = "latest",
}, "batch.node.windows amd64")
{
IsAutomaticUpdateEnabled = false,
DataDisks =
{
new BatchVmDataDisk(0,30)
{
Caching = BatchDiskCachingType.ReadWrite,
StorageAccountType = BatchStorageAccountType.PremiumLrs,
},new BatchVmDataDisk(1,200)
{
Caching = BatchDiskCachingType.None,
StorageAccountType = BatchStorageAccountType.StandardLrs,
}
},
LicenseType = "Windows_Server",
DiskEncryptionTargets =
{
BatchDiskEncryptionTarget.OSDisk,BatchDiskEncryptionTarget.TemporaryDisk
},
NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal,
OSDisk = new BatchOSDisk()
{
EphemeralOSDiskPlacement = BatchDiffDiskPlacement.CacheDisk,
},
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1")
{
EvaluationInterval = XmlConvert.ToTimeSpan("PT5M"),
},
},
NetworkConfiguration = new BatchNetworkConfiguration()
{
EndpointInboundNatPools =
{
new BatchInboundNatPool("testnat",BatchInboundEndpointProtocol.Tcp,12001,15000,15100)
{
NetworkSecurityGroupRules =
{
new BatchNetworkSecurityGroupRule(150,BatchNetworkSecurityGroupRuleAccess.Allow,"192.100.12.45")
{
SourcePortRanges =
{
"1","2"
},
},new BatchNetworkSecurityGroupRule(3500,BatchNetworkSecurityGroupRuleAccess.Deny,"*")
{
SourcePortRanges =
{
"*"
},
}
},
}
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter-SmallDisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
"licenseType": "Windows_Server",
"dataDisks": [
{
"lun": 0,
"caching": "ReadWrite",
"diskSizeGB": 30,
"storageAccountType": "Premium_LRS"
},
{
"lun": 1,
"caching": "None",
"diskSizeGB": 200,
"storageAccountType": "Standard_LRS"
}
],
"diskEncryptionConfiguration": {
"targets": [
"OsDisk",
"TemporaryDisk"
]
},
"nodePlacementConfiguration": {
"policy": "Zonal"
}
}
},
"networkConfiguration": {
"endpointConfiguration": {
"inboundNatPools": [
{
"name": "testnat",
"protocol": "TCP",
"backendPort": 12001,
"frontendPortRangeStart": 15000,
"frontendPortRangeEnd": 15100,
"networkSecurityGroupRules": [
{
"access": "Allow",
"sourceAddressPrefix": "192.100.12.45",
"priority": 150,
"sourcePortRanges": [
"1",
"2"
]
},
{
"access": "Deny",
"sourceAddressPrefix": "*",
"priority": 3500,
"sourcePortRanges": [
"*"
]
}
]
}
]
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
CreatePool - Minimal VirtualMachineConfiguration
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
}
}
}
import com.azure.resourcemanager.batch.models.AutoScaleSettings;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/
* PoolCreate_MinimalVirtualMachineConfiguration.json
*/
/**
* Sample code: CreatePool - Minimal VirtualMachineConfiguration.
*
* @param manager Entry point to BatchManager.
*/
public static void
createPoolMinimalVirtualMachineConfiguration(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(
new DeploymentConfiguration()
.withVirtualMachineConfiguration(
new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("UbuntuServer").withSku("18.04-LTS").withVersion("latest"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.withScaleSettings(new ScaleSettings().withAutoScale(new AutoScaleSettings()
.withFormula("$TargetDedicatedNodes=1").withEvaluationInterval(Duration.parse("PT5M"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_minimal_virtual_machine_configuration.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18.04-LTS",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"scaleSettings": {"autoScale": {"evaluationInterval": "PT5M", "formula": "$TargetDedicatedNodes=1"}},
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json
func ExamplePoolClient_Create_createPoolMinimalVirtualMachineConfiguration() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("UbuntuServer"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("18.04-LTS"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
ScaleSettings: &armbatch.ScaleSettings{
AutoScale: &armbatch.AutoScaleSettings{
EvaluationInterval: to.Ptr("PT5M"),
Formula: to.Ptr("$TargetDedicatedNodes=1"),
},
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("18.04-LTS"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// AutoScale: &armbatch.AutoScaleSettings{
// EvaluationInterval: to.Ptr("PT5M"),
// Formula: to.Ptr("$TargetDedicatedNodes=1"),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json
*/
async function createPoolMinimalVirtualMachineConfiguration() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "UbuntuServer",
publisher: "Canonical",
sku: "18.04-LTS",
version: "latest",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
scaleSettings: {
autoScale: {
evaluationInterval: "PT5M",
formula: "$TargetDedicatedNodes=1",
},
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18.04-LTS",
Version = "latest",
}, "batch.node.ubuntu 18.04"),
ScaleSettings = new BatchAccountPoolScaleSettings()
{
AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1")
{
EvaluationInterval = XmlConvert.ToTimeSpan("PT5M"),
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
CreatePool - No public IP
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"publicIPAddressConfiguration": {
"provision": "NoPublicIPAddresses"
}
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.IpAddressProvisioningType;
import com.azure.resourcemanager.batch.models.NetworkConfiguration;
import com.azure.resourcemanager.batch.models.PublicIpAddressConfiguration;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.
* json
*/
/**
* Sample code: CreatePool - No public IP.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolNoPublicIP(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(new DeploymentConfiguration().withVirtualMachineConfiguration(
new VirtualMachineConfiguration().withImageReference(new ImageReference().withId(
"/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.withNetworkConfiguration(new NetworkConfiguration().withSubnetId(
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123")
.withPublicIpAddressConfiguration(
new PublicIpAddressConfiguration().withProvision(IpAddressProvisioningType.NO_PUBLIC_IPADDRESSES)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_no_public_ip_addresses.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"networkConfiguration": {
"publicIPAddressConfiguration": {"provision": "NoPublicIPAddresses"},
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.json
func ExamplePoolClient_Create_createPoolNoPublicIp() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
NetworkConfiguration: &armbatch.NetworkConfiguration{
PublicIPAddressConfiguration: &armbatch.PublicIPAddressConfiguration{
Provision: to.Ptr(armbatch.IPAddressProvisioningTypeNoPublicIPAddresses),
},
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateSteady),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// NetworkConfiguration: &armbatch.NetworkConfiguration{
// PublicIPAddressConfiguration: &armbatch.PublicIPAddressConfiguration{
// Provision: to.Ptr(armbatch.IPAddressProvisioningTypeNoPublicIPAddresses),
// },
// SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
// },
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// TargetDedicatedNodes: to.Ptr[int32](0),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.json
*/
async function createPoolNoPublicIP() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
id: "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
networkConfiguration: {
publicIPAddressConfiguration: { provision: "NoPublicIPAddresses" },
subnetId:
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
}, "batch.node.ubuntu 18.04"),
NetworkConfiguration = new BatchNetworkConfiguration()
{
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration()
{
Provision = BatchIPAddressProvisioningType.NoPublicIPAddresses,
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Steady",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"publicIPAddressConfiguration": {
"provision": "NoPublicIPAddresses"
}
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 0,
"targetLowPriorityNodes": 0
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
CreatePool - Public IPs
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"publicIPAddressConfiguration": {
"provision": "UserManaged",
"ipAddressIds": [
"/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135"
]
}
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.IpAddressProvisioningType;
import com.azure.resourcemanager.batch.models.NetworkConfiguration;
import com.azure.resourcemanager.batch.models.PublicIpAddressConfiguration;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json
*/
/**
* Sample code: CreatePool - Public IPs.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolPublicIPs(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(new DeploymentConfiguration().withVirtualMachineConfiguration(
new VirtualMachineConfiguration().withImageReference(new ImageReference().withId(
"/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.withNetworkConfiguration(new NetworkConfiguration().withSubnetId(
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123")
.withPublicIpAddressConfiguration(new PublicIpAddressConfiguration()
.withProvision(IpAddressProvisioningType.USER_MANAGED)
.withIpAddressIds(Arrays.asList(
"/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_public_ips.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"networkConfiguration": {
"publicIPAddressConfiguration": {
"ipAddressIds": [
"/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135"
],
"provision": "UserManaged",
},
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json
func ExamplePoolClient_Create_createPoolPublicIPs() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
NetworkConfiguration: &armbatch.NetworkConfiguration{
PublicIPAddressConfiguration: &armbatch.PublicIPAddressConfiguration{
IPAddressIDs: []*string{
to.Ptr("/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135")},
Provision: to.Ptr(armbatch.IPAddressProvisioningTypeUserManaged),
},
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateSteady),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// ID: to.Ptr("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// NetworkConfiguration: &armbatch.NetworkConfiguration{
// PublicIPAddressConfiguration: &armbatch.PublicIPAddressConfiguration{
// IPAddressIDs: []*string{
// to.Ptr("/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135")},
// Provision: to.Ptr(armbatch.IPAddressProvisioningTypeUserManaged),
// },
// SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
// },
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// TargetDedicatedNodes: to.Ptr[int32](0),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json
*/
async function createPoolPublicIPs() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
id: "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
networkConfiguration: {
publicIPAddressConfiguration: {
ipAddressIds: [
"/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135",
],
provision: "UserManaged",
},
subnetId:
"/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"),
}, "batch.node.ubuntu 18.04"),
NetworkConfiguration = new BatchNetworkConfiguration()
{
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"),
PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration()
{
Provision = BatchIPAddressProvisioningType.UserManaged,
IPAddressIds =
{
new ResourceIdentifier("/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135")
},
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Steady",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"networkConfiguration": {
"subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123",
"publicIPAddressConfiguration": {
"provision": "UserManaged",
"ipAddressIds": [
"/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135"
]
}
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"id": "/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 0,
"targetLowPriorityNodes": 0
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "Standard_d4s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18_04-lts-gen2",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"resourceTags": {
"TagName1": "TagValue1",
"TagName2": "TagValue2"
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json
*/
/**
* Sample code: CreatePool - ResourceTags.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolResourceTags(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("Standard_d4s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical").withOffer("UbuntuServer")
.withSku("18_04-lts-gen2").withVersion("latest"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(1).withTargetLowPriorityNodes(0)))
.withResourceTags(mapOf("TagName1", "TagValue1", "TagName2", "TagValue2")).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_resource_tags.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18_04-lts-gen2",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"resourceTags": {"TagName1": "TagValue1", "TagName2": "TagValue2"},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}},
"vmSize": "Standard_d4s_v3",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json
func ExamplePoolClient_Create_createPoolResourceTags() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("UbuntuServer"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("18_04-lts-gen2"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
ResourceTags: map[string]*string{
"TagName1": to.Ptr("TagValue1"),
"TagName2": to.Ptr("TagValue2"),
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](1),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
VMSize: to.Ptr("Standard_d4s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB554F8E08BCF4\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("18_04-lts-gen2"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-27T07:33:13.062Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](1),
// },
// ResourceTags: map[string]*string{
// "TagName1": to.Ptr("TagValue1"),
// "TagName2": to.Ptr("TagValue2"),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](1),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4S_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json
*/
async function createPoolResourceTags() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "UbuntuServer",
publisher: "Canonical",
sku: "18_04-lts-gen2",
version: "latest",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
resourceTags: { tagName1: "TagValue1", tagName2: "TagValue2" },
scaleSettings: {
fixedScale: { targetDedicatedNodes: 1, targetLowPriorityNodes: 0 },
},
vmSize: "Standard_d4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d4s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18_04-lts-gen2",
Version = "latest",
}, "batch.node.ubuntu 18.04"),
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
},
},
ResourceTags =
{
["TagName1"] = "TagValue1",
["TagName2"] = "TagValue2",
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB554F8E08BCF4"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB554F8E08BCF4\"",
"properties": {
"lastModified": "2023-06-14T07:03:58.3231917Z",
"creationTime": "2023-06-14T07:03:58.3231917Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"vmSize": "STANDARD_D4S_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18_04-lts-gen2",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 1,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-09-27T07:33:13.0625789Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0,
"resourceTags": {
"TagName1": "TagValue1",
"TagName2": "TagValue2"
}
}
}
CreatePool - SecurityProfile
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "Standard_d4s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18_04-lts-gen2",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
"securityProfile": {
"securityType": "trustedLaunch",
"encryptionAtHost": true,
"uefiSettings": {
"secureBootEnabled": null,
"vTpmEnabled": false
}
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.SecurityProfile;
import com.azure.resourcemanager.batch.models.SecurityTypes;
import com.azure.resourcemanager.batch.models.UefiSettings;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json
*/
/**
* Sample code: CreatePool - SecurityProfile.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolSecurityProfile(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("Standard_d4s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration()
.withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical").withOffer("UbuntuServer")
.withSku("18_04-lts-gen2").withVersion("latest"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")
.withSecurityProfile(new SecurityProfile().withSecurityType(SecurityTypes.TRUSTED_LAUNCH)
.withEncryptionAtHost(true).withUefiSettings(new UefiSettings().withVTpmEnabled(false)))))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(1).withTargetLowPriorityNodes(0)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_security_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18_04-lts-gen2",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
"securityProfile": {
"encryptionAtHost": True,
"securityType": "trustedLaunch",
"uefiSettings": {"secureBootEnabled": None, "vTpmEnabled": False},
},
}
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}},
"vmSize": "Standard_d4s_v3",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json
func ExamplePoolClient_Create_createPoolSecurityProfile() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("UbuntuServer"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("18_04-lts-gen2"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
SecurityProfile: &armbatch.SecurityProfile{
EncryptionAtHost: to.Ptr(true),
SecurityType: to.Ptr(armbatch.SecurityTypesTrustedLaunch),
UefiSettings: &armbatch.UefiSettings{
VTpmEnabled: to.Ptr(false),
},
},
},
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](1),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
VMSize: to.Ptr("Standard_d4s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB554F8E08BCF4\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("18_04-lts-gen2"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// SecurityProfile: &armbatch.SecurityProfile{
// EncryptionAtHost: to.Ptr(true),
// SecurityType: to.Ptr(armbatch.SecurityTypesTrustedLaunch),
// UefiSettings: &armbatch.UefiSettings{
// VTpmEnabled: to.Ptr(false),
// },
// },
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](1),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](1),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4S_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json
*/
async function createPoolSecurityProfile() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "UbuntuServer",
publisher: "Canonical",
sku: "18_04-lts-gen2",
version: "latest",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
securityProfile: {
encryptionAtHost: true,
securityType: "trustedLaunch",
uefiSettings: { secureBootEnabled: undefined, vTpmEnabled: false },
},
},
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 1, targetLowPriorityNodes: 0 },
},
vmSize: "Standard_d4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d4s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18_04-lts-gen2",
Version = "latest",
}, "batch.node.ubuntu 18.04")
{
SecurityProfile = new BatchSecurityProfile()
{
SecurityType = BatchSecurityType.TrustedLaunch,
EncryptionAtHost = true,
UefiSettings = new BatchUefiSettings()
{
IsSecureBootEnabled = null,
IsVTpmEnabled = false,
},
},
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB554F8E08BCF4"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB554F8E08BCF4\"",
"properties": {
"lastModified": "2023-06-14T07:03:58.3231917Z",
"creationTime": "2023-06-14T07:03:58.3231917Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"vmSize": "STANDARD_D4S_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18_04-lts-gen2",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
"securityProfile": {
"securityType": "trustedLaunch",
"encryptionAtHost": true,
"uefiSettings": {
"vTpmEnabled": false
}
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 1,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-06-14T07:03:58.3231917Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"tags": {
"TagName1": "TagValue1",
"TagName2": "TagValue2"
},
"properties": {
"vmSize": "Standard_d4s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-jammy",
"sku": "22_04-lts",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 22.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json
*/
/**
* Sample code: CreatePool - Tags.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolTags(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withTags(mapOf("TagName1", "TagValue1", "TagName2", "TagValue2")).withVmSize("Standard_d4s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("0001-com-ubuntu-server-jammy").withSku("22_04-lts").withVersion("latest"))
.withNodeAgentSkuId("batch.node.ubuntu 22.04")))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(1).withTargetLowPriorityNodes(0)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_tags.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "0001-com-ubuntu-server-jammy",
"publisher": "Canonical",
"sku": "22_04-lts",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.ubuntu 22.04",
}
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}},
"vmSize": "Standard_d4s_v3",
},
"tags": {"TagName1": "TagValue1", "TagName2": "TagValue2"},
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json
func ExamplePoolClient_Create_createPoolTags() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Tags: map[string]*string{
"TagName1": to.Ptr("TagValue1"),
"TagName2": to.Ptr("TagValue2"),
},
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("0001-com-ubuntu-server-jammy"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("22_04-lts"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 22.04"),
},
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](1),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
VMSize: to.Ptr("Standard_d4s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB554F8E08BCF4\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Tags: map[string]*string{
// "TagName1": to.Ptr("TagValue1"),
// "TagName2": to.Ptr("TagValue2"),
// },
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("0001-com-ubuntu-server-jammy"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("22_04-lts"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 22.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-14T07:03:58.323Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-27T07:33:13.062Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](1),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](1),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4S_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json
*/
async function createPoolTags() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "0001-com-ubuntu-server-jammy",
publisher: "Canonical",
sku: "22_04-lts",
version: "latest",
},
nodeAgentSkuId: "batch.node.ubuntu 22.04",
},
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 1, targetLowPriorityNodes: 0 },
},
tags: { tagName1: "TagValue1", tagName2: "TagValue2" },
vmSize: "Standard_d4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d4s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-jammy",
Sku = "22_04-lts",
Version = "latest",
}, "batch.node.ubuntu 22.04"),
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
},
},
Tags =
{
["TagName1"] = "TagValue1",
["TagName2"] = "TagValue2",
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB554F8E08BCF4"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB554F8E08BCF4\"",
"properties": {
"lastModified": "2023-06-14T07:03:58.3231917Z",
"creationTime": "2023-06-14T07:03:58.3231917Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-06-14T07:03:58.3231917Z",
"vmSize": "STANDARD_D4S_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-jammy",
"sku": "22_04-lts",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 22.04"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 1,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-09-27T07:33:13.0625789Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
},
"tags": {
"TagName1": "TagValue1",
"TagName2": "TagValue2"
}
}
CreatePool - UpgradePolicy
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "Standard_d4s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest"
},
"nodePlacementConfiguration": {
"policy": "Zonal"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 2,
"targetLowPriorityNodes": 0
}
},
"upgradePolicy": {
"mode": "automatic",
"automaticOSUpgradePolicy": {
"disableAutomaticRollback": true,
"enableAutomaticOSUpgrade": true,
"useRollingUpgradePolicy": true,
"osRollingUpgradeDeferral": true
},
"rollingUpgradePolicy": {
"enableCrossZoneUpgrade": true,
"maxBatchInstancePercent": 20,
"maxUnhealthyInstancePercent": 20,
"maxUnhealthyUpgradedInstancePercent": 20,
"pauseTimeBetweenBatches": "PT0S",
"prioritizeUnhealthyInstances": false,
"rollbackFailedInstancesOnPolicyBreach": false
}
}
}
}
import com.azure.resourcemanager.batch.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.NodePlacementConfiguration;
import com.azure.resourcemanager.batch.models.NodePlacementPolicyType;
import com.azure.resourcemanager.batch.models.RollingUpgradePolicy;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.UpgradeMode;
import com.azure.resourcemanager.batch.models.UpgradePolicy;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import com.azure.resourcemanager.batch.models.WindowsConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json
*/
/**
* Sample code: CreatePool - UpgradePolicy.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolUpgradePolicy(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("Standard_d4s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2019-datacenter-smalldisk").withVersion("latest"))
.withNodeAgentSkuId("batch.node.windows amd64")
.withWindowsConfiguration(new WindowsConfiguration().withEnableAutomaticUpdates(false))
.withNodePlacementConfiguration(
new NodePlacementConfiguration().withPolicy(NodePlacementPolicyType.ZONAL))))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(2).withTargetLowPriorityNodes(0)))
.withUpgradePolicy(
new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withDisableAutomaticRollback(true)
.withEnableAutomaticOSUpgrade(true).withUseRollingUpgradePolicy(true)
.withOsRollingUpgradeDeferral(true))
.withRollingUpgradePolicy(new RollingUpgradePolicy().withEnableCrossZoneUpgrade(true)
.withMaxBatchInstancePercent(20).withMaxUnhealthyInstancePercent(20)
.withMaxUnhealthyUpgradedInstancePercent(20).withPauseTimeBetweenBatches("PT0S")
.withPrioritizeUnhealthyInstances(false).withRollbackFailedInstancesOnPolicyBreach(false)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_upgrade_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.windows amd64",
"nodePlacementConfiguration": {"policy": "Zonal"},
"windowsConfiguration": {"enableAutomaticUpdates": False},
}
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 2, "targetLowPriorityNodes": 0}},
"upgradePolicy": {
"automaticOSUpgradePolicy": {
"disableAutomaticRollback": True,
"enableAutomaticOSUpgrade": True,
"osRollingUpgradeDeferral": True,
"useRollingUpgradePolicy": True,
},
"mode": "automatic",
"rollingUpgradePolicy": {
"enableCrossZoneUpgrade": True,
"maxBatchInstancePercent": 20,
"maxUnhealthyInstancePercent": 20,
"maxUnhealthyUpgradedInstancePercent": 20,
"pauseTimeBetweenBatches": "PT0S",
"prioritizeUnhealthyInstances": False,
"rollbackFailedInstancesOnPolicyBreach": False,
},
},
"vmSize": "Standard_d4s_v3",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json
func ExamplePoolClient_Create_createPoolUpgradePolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2019-datacenter-smalldisk"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
NodePlacementConfiguration: &armbatch.NodePlacementConfiguration{
Policy: to.Ptr(armbatch.NodePlacementPolicyTypeZonal),
},
WindowsConfiguration: &armbatch.WindowsConfiguration{
EnableAutomaticUpdates: to.Ptr(false),
},
},
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](2),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
UpgradePolicy: &armbatch.UpgradePolicy{
AutomaticOSUpgradePolicy: &armbatch.AutomaticOSUpgradePolicy{
DisableAutomaticRollback: to.Ptr(true),
EnableAutomaticOSUpgrade: to.Ptr(true),
OSRollingUpgradeDeferral: to.Ptr(true),
UseRollingUpgradePolicy: to.Ptr(true),
},
Mode: to.Ptr(armbatch.UpgradeModeAutomatic),
RollingUpgradePolicy: &armbatch.RollingUpgradePolicy{
EnableCrossZoneUpgrade: to.Ptr(true),
MaxBatchInstancePercent: to.Ptr[int32](20),
MaxUnhealthyInstancePercent: to.Ptr[int32](20),
MaxUnhealthyUpgradedInstancePercent: to.Ptr[int32](20),
PauseTimeBetweenBatches: to.Ptr("PT0S"),
PrioritizeUnhealthyInstances: to.Ptr(false),
RollbackFailedInstancesOnPolicyBreach: to.Ptr(false),
},
},
VMSize: to.Ptr("Standard_d4s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB51E64D3C3B69\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T06:16:44.237Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T06:16:44.237Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2019-datacenter-smalldisk"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
// NodePlacementConfiguration: &armbatch.NodePlacementConfiguration{
// Policy: to.Ptr(armbatch.NodePlacementPolicyTypeZonal),
// },
// WindowsConfiguration: &armbatch.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(false),
// },
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T06:16:44.237Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T06:16:44.237Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T06:16:44.237Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](2),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](2),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// UpgradePolicy: &armbatch.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armbatch.AutomaticOSUpgradePolicy{
// DisableAutomaticRollback: to.Ptr(true),
// EnableAutomaticOSUpgrade: to.Ptr(true),
// OSRollingUpgradeDeferral: to.Ptr(true),
// UseRollingUpgradePolicy: to.Ptr(true),
// },
// Mode: to.Ptr(armbatch.UpgradeModeAutomatic),
// RollingUpgradePolicy: &armbatch.RollingUpgradePolicy{
// EnableCrossZoneUpgrade: to.Ptr(true),
// MaxBatchInstancePercent: to.Ptr[int32](20),
// MaxUnhealthyInstancePercent: to.Ptr[int32](20),
// MaxUnhealthyUpgradedInstancePercent: to.Ptr[int32](20),
// PauseTimeBetweenBatches: to.Ptr("PT0S"),
// PrioritizeUnhealthyInstances: to.Ptr(false),
// RollbackFailedInstancesOnPolicyBreach: to.Ptr(false),
// },
// },
// VMSize: to.Ptr("STANDARD_D4S_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json
*/
async function createPoolUpgradePolicy() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2019-datacenter-smalldisk",
version: "latest",
},
nodeAgentSkuId: "batch.node.windows amd64",
nodePlacementConfiguration: { policy: "Zonal" },
windowsConfiguration: { enableAutomaticUpdates: false },
},
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 2, targetLowPriorityNodes: 0 },
},
upgradePolicy: {
automaticOSUpgradePolicy: {
disableAutomaticRollback: true,
enableAutomaticOSUpgrade: true,
osRollingUpgradeDeferral: true,
useRollingUpgradePolicy: true,
},
mode: "automatic",
rollingUpgradePolicy: {
enableCrossZoneUpgrade: true,
maxBatchInstancePercent: 20,
maxUnhealthyInstancePercent: 20,
maxUnhealthyUpgradedInstancePercent: 20,
pauseTimeBetweenBatches: "PT0S",
prioritizeUnhealthyInstances: false,
rollbackFailedInstancesOnPolicyBreach: false,
},
},
vmSize: "Standard_d4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d4s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2019-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64")
{
IsAutomaticUpdateEnabled = false,
NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal,
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 2,
TargetLowPriorityNodes = 0,
},
},
UpgradePolicy = new UpgradePolicy(UpgradeMode.Automatic)
{
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy()
{
DisableAutomaticRollback = true,
EnableAutomaticOSUpgrade = true,
UseRollingUpgradePolicy = true,
OSRollingUpgradeDeferral = true,
},
RollingUpgradePolicy = new RollingUpgradePolicy()
{
EnableCrossZoneUpgrade = true,
MaxBatchInstancePercent = 20,
MaxUnhealthyInstancePercent = 20,
MaxUnhealthyUpgradedInstancePercent = 20,
PauseTimeBetweenBatches = "PT0S",
PrioritizeUnhealthyInstances = false,
RollbackFailedInstancesOnPolicyBreach = false,
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB51E64D3C3B69"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB51E64D3C3B69\"",
"properties": {
"lastModified": "2023-05-11T06:16:44.2372184Z",
"creationTime": "2023-05-11T06:16:44.2372184Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-05-11T06:16:44.2372184Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-05-11T06:16:44.2372184Z",
"vmSize": "STANDARD_D4S_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
"nodePlacementConfiguration": {
"policy": "Zonal"
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 2,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 2,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-05-11T06:16:44.2372184Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0,
"upgradePolicy": {
"mode": "automatic",
"automaticOSUpgradePolicy": {
"disableAutomaticRollback": true,
"enableAutomaticOSUpgrade": true,
"useRollingUpgradePolicy": true,
"osRollingUpgradeDeferral": true
},
"rollingUpgradePolicy": {
"enableCrossZoneUpgrade": true,
"maxBatchInstancePercent": 20,
"maxUnhealthyInstancePercent": 20,
"maxUnhealthyUpgradedInstancePercent": 20,
"pauseTimeBetweenBatches": "PT0S",
"prioritizeUnhealthyInstances": false,
"rollbackFailedInstancesOnPolicyBreach": false
}
}
}
}
CreatePool - UserAssignedIdentities
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
}
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {},
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {}
}
}
}
import com.azure.resourcemanager.batch.models.AutoScaleSettings;
import com.azure.resourcemanager.batch.models.BatchPoolIdentity;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.PoolIdentityType;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.UserAssignedIdentities;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities
* .json
*/
/**
* Sample code: CreatePool - UserAssignedIdentities.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolUserAssignedIdentities(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withIdentity(new BatchPoolIdentity().withType(PoolIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1",
new UserAssignedIdentities(),
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2",
new UserAssignedIdentities())))
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(
new DeploymentConfiguration()
.withVirtualMachineConfiguration(
new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("UbuntuServer").withSku("18.04-LTS").withVersion("latest"))
.withNodeAgentSkuId("batch.node.ubuntu 18.04")))
.withScaleSettings(new ScaleSettings().withAutoScale(new AutoScaleSettings()
.withFormula("$TargetDedicatedNodes=1").withEvaluationInterval(Duration.parse("PT5M"))))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_user_assigned_identities.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {},
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {},
},
},
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18.04-LTS",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04",
}
},
"scaleSettings": {"autoScale": {"evaluationInterval": "PT5M", "formula": "$TargetDedicatedNodes=1"}},
"vmSize": "STANDARD_D4",
},
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities.json
func ExamplePoolClient_Create_createPoolUserAssignedIdentities() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Identity: &armbatch.PoolIdentity{
Type: to.Ptr(armbatch.PoolIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armbatch.UserAssignedIdentities{
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {},
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {},
},
},
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("UbuntuServer"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("18.04-LTS"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
},
},
ScaleSettings: &armbatch.ScaleSettings{
AutoScale: &armbatch.AutoScaleSettings{
EvaluationInterval: to.Ptr("PT5M"),
Formula: to.Ptr("$TargetDedicatedNodes=1"),
},
},
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Identity: &armbatch.PoolIdentity{
// Type: to.Ptr(armbatch.PoolIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armbatch.UserAssignedIdentities{
// "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armbatch.UserAssignedIdentities{
// ClientID: to.Ptr("clientId1"),
// PrincipalID: to.Ptr("principalId1"),
// },
// "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armbatch.UserAssignedIdentities{
// ClientID: to.Ptr("clientId2"),
// PrincipalID: to.Ptr("principalId2"),
// },
// },
// },
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-01T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-01T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("UbuntuServer"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("18.04-LTS"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 18.04"),
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-01T10:22:55.940Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-01T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// AutoScale: &armbatch.AutoScaleSettings{
// EvaluationInterval: to.Ptr("PT5M"),
// Formula: to.Ptr("$TargetDedicatedNodes=1"),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities.json
*/
async function createPoolUserAssignedIdentities() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "UbuntuServer",
publisher: "Canonical",
sku: "18.04-LTS",
version: "latest",
},
nodeAgentSkuId: "batch.node.ubuntu 18.04",
},
},
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/subid/resourceGroups/defaultAzurebatchJapaneast/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1":
{},
"/subscriptions/subid/resourceGroups/defaultAzurebatchJapaneast/providers/MicrosoftManagedIdentity/userAssignedIdentities/id2":
{},
},
},
scaleSettings: {
autoScale: {
evaluationInterval: "PT5M",
formula: "$TargetDedicatedNodes=1",
},
},
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
Identity = new ManagedServiceIdentity("UserAssigned")
{
UserAssignedIdentities =
{
[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(),
[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(),
},
},
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18.04-LTS",
Version = "latest",
}, "batch.node.ubuntu 18.04"),
ScaleSettings = new BatchAccountPoolScaleSettings()
{
AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1")
{
EvaluationInterval = XmlConvert.ToTimeSpan("PT5M"),
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2020-10-01T10:22:55.9407275Z",
"creationTime": "2020-10-01T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2020-10-01T10:22:55.9407275Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2020-10-01T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.ubuntu 18.04"
}
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {
"principalId": "principalId1",
"clientId": "clientId1"
},
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {
"principalId": "principalId2",
"clientId": "clientId2"
}
}
}
}
CreatePool - VirtualMachineConfiguration Extensions
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "STANDARD_D4",
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts"
},
"nodeAgentSkuId": "batch.node.ubuntu 20.04",
"extensions": [
{
"name": "batchextension1",
"type": "KeyVaultForLinux",
"publisher": "Microsoft.Azure.KeyVault",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettingsKey": "secretsManagementSettingsValue",
"authenticationSettingsKey": "authenticationSettingsValue"
}
}
]
}
},
"targetNodeCommunicationMode": "Default"
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.batch.models.AutoScaleSettings;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.NodeCommunicationMode;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.VMExtension;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.io.IOException;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/
* PoolCreate_VirtualMachineConfiguration_Extensions.json
*/
/**
* Sample code: CreatePool - VirtualMachineConfiguration Extensions.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolVirtualMachineConfigurationExtensions(
com.azure.resourcemanager.batch.BatchManager manager) throws IOException {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("STANDARD_D4")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("Canonical")
.withOffer("0001-com-ubuntu-server-focal").withSku("20_04-lts"))
.withNodeAgentSkuId("batch.node.ubuntu 20.04")
.withExtensions(Arrays.asList(new VMExtension().withName("batchextension1")
.withPublisher("Microsoft.Azure.KeyVault").withType("KeyVaultForLinux")
.withTypeHandlerVersion("2.0").withAutoUpgradeMinorVersion(true)
.withEnableAutomaticUpgrade(true)
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize(
"{\"authenticationSettingsKey\":\"authenticationSettingsValue\",\"secretsManagementSettingsKey\":\"secretsManagementSettingsValue\"}",
Object.class, SerializerEncoding.JSON))))))
.withScaleSettings(new ScaleSettings().withAutoScale(new AutoScaleSettings()
.withFormula("$TargetDedicatedNodes=1").withEvaluationInterval(Duration.parse("PT5M"))))
.withTargetNodeCommunicationMode(NodeCommunicationMode.DEFAULT).create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_virtual_machine_configuration_extensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"extensions": [
{
"autoUpgradeMinorVersion": True,
"enableAutomaticUpgrade": True,
"name": "batchextension1",
"publisher": "Microsoft.Azure.KeyVault",
"settings": {
"authenticationSettingsKey": "authenticationSettingsValue",
"secretsManagementSettingsKey": "secretsManagementSettingsValue",
},
"type": "KeyVaultForLinux",
"typeHandlerVersion": "2.0",
}
],
"imageReference": {
"offer": "0001-com-ubuntu-server-focal",
"publisher": "Canonical",
"sku": "20_04-lts",
},
"nodeAgentSkuId": "batch.node.ubuntu 20.04",
}
},
"scaleSettings": {"autoScale": {"evaluationInterval": "PT5M", "formula": "$TargetDedicatedNodes=1"}},
"targetNodeCommunicationMode": "Default",
"vmSize": "STANDARD_D4",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json
func ExamplePoolClient_Create_createPoolVirtualMachineConfigurationExtensions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("0001-com-ubuntu-server-focal"),
Publisher: to.Ptr("Canonical"),
SKU: to.Ptr("20_04-lts"),
},
NodeAgentSKUID: to.Ptr("batch.node.ubuntu 20.04"),
Extensions: []*armbatch.VMExtension{
{
Name: to.Ptr("batchextension1"),
Type: to.Ptr("KeyVaultForLinux"),
AutoUpgradeMinorVersion: to.Ptr(true),
EnableAutomaticUpgrade: to.Ptr(true),
Publisher: to.Ptr("Microsoft.Azure.KeyVault"),
Settings: map[string]any{
"authenticationSettingsKey": "authenticationSettingsValue",
"secretsManagementSettingsKey": "secretsManagementSettingsValue",
},
TypeHandlerVersion: to.Ptr("2.0"),
}},
},
},
ScaleSettings: &armbatch.ScaleSettings{
AutoScale: &armbatch.AutoScaleSettings{
EvaluationInterval: to.Ptr("PT5M"),
Formula: to.Ptr("$TargetDedicatedNodes=1"),
},
},
TargetNodeCommunicationMode: to.Ptr(armbatch.NodeCommunicationModeDefault),
VMSize: to.Ptr("STANDARD_D4"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8D4EDFEBFADF4AB\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("0001-com-ubuntu-server-focal"),
// Publisher: to.Ptr("Canonical"),
// SKU: to.Ptr("20_04-lts"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.ubuntu 20.04"),
// Extensions: []*armbatch.VMExtension{
// {
// Name: to.Ptr("batchextension1"),
// Type: to.Ptr("KeyVaultForLinux"),
// AutoUpgradeMinorVersion: to.Ptr(true),
// EnableAutomaticUpgrade: to.Ptr(true),
// Publisher: to.Ptr("Microsoft.Azure.KeyVault"),
// Settings: map[string]any{
// "authenticationSettingsKey": "authenticationSettingsValue",
// "secretsManagementSettingsKey": "secretsManagementSettingsValue",
// },
// TypeHandlerVersion: to.Ptr("2.0"),
// }},
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-28T10:22:55.940Z"); return t}()),
// ScaleSettings: &armbatch.ScaleSettings{
// AutoScale: &armbatch.AutoScaleSettings{
// EvaluationInterval: to.Ptr("PT5M"),
// Formula: to.Ptr("$TargetDedicatedNodes=1"),
// },
// },
// TargetNodeCommunicationMode: to.Ptr(armbatch.NodeCommunicationModeDefault),
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D4"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json
*/
async function createPoolVirtualMachineConfigurationExtensions() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "0001-com-ubuntu-server-focal",
publisher: "Canonical",
sku: "20_04-lts",
},
nodeAgentSkuId: "batch.node.ubuntu 20.04",
extensions: [
{
name: "batchextension1",
type: "KeyVaultForLinux",
autoUpgradeMinorVersion: true,
enableAutomaticUpgrade: true,
publisher: "Microsoft.Azure.KeyVault",
settings: {
authenticationSettingsKey: "authenticationSettingsValue",
secretsManagementSettingsKey: "secretsManagementSettingsValue",
},
typeHandlerVersion: "2.0",
},
],
},
},
scaleSettings: {
autoScale: {
evaluationInterval: "PT5M",
formula: "$TargetDedicatedNodes=1",
},
},
targetNodeCommunicationMode: "Default",
vmSize: "STANDARD_D4",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "STANDARD_D4",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-focal",
Sku = "20_04-lts",
}, "batch.node.ubuntu 20.04")
{
Extensions =
{
new BatchVmExtension("batchextension1","Microsoft.Azure.KeyVault","KeyVaultForLinux")
{
TypeHandlerVersion = "2.0",
AutoUpgradeMinorVersion = true,
EnableAutomaticUpgrade = true,
Settings = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["authenticationSettingsKey"] = "authenticationSettingsValue",
["secretsManagementSettingsKey"] = "secretsManagementSettingsValue"}),
}
},
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1")
{
EvaluationInterval = XmlConvert.ToTimeSpan("PT5M"),
},
},
TargetNodeCommunicationMode = NodeCommunicationMode.Default,
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8D4EDFEBFADF4AB"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8D4EDFEBFADF4AB\"",
"properties": {
"lastModified": "2017-08-28T10:22:55.9407275Z",
"creationTime": "2017-08-28T10:22:55.9407275Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2017-08-28T10:22:55.9407275Z",
"vmSize": "STANDARD_D4",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"scaleSettings": {
"autoScale": {
"formula": "$TargetDedicatedNodes=1",
"evaluationInterval": "PT5M"
}
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0,
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "Canonical",
"offer": "0001-com-ubuntu-server-focal",
"sku": "20_04-lts"
},
"nodeAgentSkuId": "batch.node.ubuntu 20.04",
"extensions": [
{
"name": "batchextension1",
"type": "KeyVaultForLinux",
"publisher": "Microsoft.Azure.KeyVault",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"secretsManagementSettingsKey": "secretsManagementSettingsValue",
"authenticationSettingsKey": "authenticationSettingsValue"
}
}
]
}
},
"targetNodeCommunicationMode": "Default"
}
}
CreatePool - VirtualMachineConfiguration OSDisk
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "Standard_d2s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "microsoftwindowsserver",
"offer": "windowsserver",
"sku": "2022-datacenter-smalldisk"
},
"osDisk": {
"diskSizeGB": 100,
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"caching": "ReadWrite",
"writeAcceleratorEnabled": false
},
"nodeAgentSkuId": "batch.node.windows amd64"
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0
}
}
}
}
import com.azure.resourcemanager.batch.models.CachingType;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ManagedDisk;
import com.azure.resourcemanager.batch.models.OSDisk;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.StorageAccountType;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/
* PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json
*/
/**
* Sample code: CreatePool - VirtualMachineConfiguration OSDisk.
*
* @param manager Entry point to BatchManager.
*/
public static void
createPoolVirtualMachineConfigurationOSDisk(com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("Standard_d2s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("microsoftwindowsserver")
.withOffer("windowsserver").withSku("2022-datacenter-smalldisk"))
.withNodeAgentSkuId("batch.node.windows amd64")
.withOsDisk(new OSDisk().withCaching(CachingType.READ_WRITE)
.withManagedDisk(new ManagedDisk().withStorageAccountType(StorageAccountType.STANDARD_SSD_LRS))
.withDiskSizeGB(100).withWriteAcceleratorEnabled(false))))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(1).withTargetLowPriorityNodes(0)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_virtual_machine_configuration_managed_os_disk.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "windowsserver",
"publisher": "microsoftwindowsserver",
"sku": "2022-datacenter-smalldisk",
},
"nodeAgentSkuId": "batch.node.windows amd64",
"osDisk": {
"caching": "ReadWrite",
"diskSizeGB": 100,
"managedDisk": {"storageAccountType": "StandardSSD_LRS"},
"writeAcceleratorEnabled": False,
},
}
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}},
"vmSize": "Standard_d2s_v3",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json
func ExamplePoolClient_Create_createPoolVirtualMachineConfigurationOsDisk() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("windowsserver"),
Publisher: to.Ptr("microsoftwindowsserver"),
SKU: to.Ptr("2022-datacenter-smalldisk"),
},
NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
OSDisk: &armbatch.OSDisk{
Caching: to.Ptr(armbatch.CachingTypeReadWrite),
DiskSizeGB: to.Ptr[int32](100),
ManagedDisk: &armbatch.ManagedDisk{
StorageAccountType: to.Ptr(armbatch.StorageAccountTypeStandardSSDLRS),
},
WriteAcceleratorEnabled: to.Ptr(false),
},
},
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](1),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
VMSize: to.Ptr("Standard_d2s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("testpool"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB51F396992B8D\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T02:12:27.752Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T02:12:27.752Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("windowsserver"),
// Publisher: to.Ptr("microsoftwindowsserver"),
// SKU: to.Ptr("2022-datacenter-smalldisk"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
// OSDisk: &armbatch.OSDisk{
// Caching: to.Ptr(armbatch.CachingTypeReadWrite),
// DiskSizeGB: to.Ptr[int32](100),
// ManagedDisk: &armbatch.ManagedDisk{
// StorageAccountType: to.Ptr(armbatch.StorageAccountTypeStandardSSDLRS),
// },
// WriteAcceleratorEnabled: to.Ptr(false),
// },
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T02:12:27.752Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T02:12:27.752Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T02:12:27.752Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](1),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](1),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// VMSize: to.Ptr("STANDARD_D2_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json
*/
async function createPoolVirtualMachineConfigurationOSDisk() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "windowsserver",
publisher: "microsoftwindowsserver",
sku: "2022-datacenter-smalldisk",
},
nodeAgentSkuId: "batch.node.windows amd64",
osDisk: {
caching: "ReadWrite",
diskSizeGB: 100,
managedDisk: { storageAccountType: "StandardSSD_LRS" },
writeAcceleratorEnabled: false,
},
},
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 1, targetLowPriorityNodes: 0 },
},
vmSize: "Standard_d2s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d2s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "microsoftwindowsserver",
Offer = "windowsserver",
Sku = "2022-datacenter-smalldisk",
}, "batch.node.windows amd64")
{
OSDisk = new BatchOSDisk()
{
Caching = BatchDiskCachingType.ReadWrite,
ManagedDisk = new ManagedDisk()
{
StorageAccountType = BatchStorageAccountType.StandardSsdLrs,
},
DiskSizeGB = 100,
IsWriteAcceleratorEnabled = false,
},
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB51F14DC1A8AD"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "testpool",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB51F396992B8D\"",
"properties": {
"lastModified": "2023-08-24T02:12:27.7527697Z",
"creationTime": "2023-08-24T02:12:27.7527697Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-08-24T02:12:27.7527697Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-08-24T02:12:27.7527697Z",
"vmSize": "STANDARD_D2_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "microsoftwindowsserver",
"offer": "windowsserver",
"sku": "2022-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"diskSizeGB": 100,
"writeAcceleratorEnabled": false
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 1,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 1,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-08-24T02:12:27.7527697Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0
}
}
CreatePool - VirtualMachineConfiguration ServiceArtifactReference
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool?api-version=2024-07-01
{
"properties": {
"vmSize": "Standard_d4s_v3",
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
"serviceArtifactReference": {
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 2,
"targetLowPriorityNodes": 0
}
},
"upgradePolicy": {
"mode": "automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
import com.azure.resourcemanager.batch.models.AutomaticOSUpgradePolicy;
import com.azure.resourcemanager.batch.models.DeploymentConfiguration;
import com.azure.resourcemanager.batch.models.FixedScaleSettings;
import com.azure.resourcemanager.batch.models.ImageReference;
import com.azure.resourcemanager.batch.models.ScaleSettings;
import com.azure.resourcemanager.batch.models.ServiceArtifactReference;
import com.azure.resourcemanager.batch.models.UpgradeMode;
import com.azure.resourcemanager.batch.models.UpgradePolicy;
import com.azure.resourcemanager.batch.models.VirtualMachineConfiguration;
import com.azure.resourcemanager.batch.models.WindowsConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Pool Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/
* PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json
*/
/**
* Sample code: CreatePool - VirtualMachineConfiguration ServiceArtifactReference.
*
* @param manager Entry point to BatchManager.
*/
public static void createPoolVirtualMachineConfigurationServiceArtifactReference(
com.azure.resourcemanager.batch.BatchManager manager) {
manager.pools().define("testpool").withExistingBatchAccount("default-azurebatch-japaneast", "sampleacct")
.withVmSize("Standard_d4s_v3")
.withDeploymentConfiguration(
new DeploymentConfiguration().withVirtualMachineConfiguration(new VirtualMachineConfiguration()
.withImageReference(new ImageReference().withPublisher("MicrosoftWindowsServer")
.withOffer("WindowsServer").withSku("2019-datacenter-smalldisk").withVersion("latest"))
.withNodeAgentSkuId("batch.node.windows amd64")
.withWindowsConfiguration(new WindowsConfiguration().withEnableAutomaticUpdates(false))
.withServiceArtifactReference(new ServiceArtifactReference().withId(
"/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"))))
.withScaleSettings(new ScaleSettings()
.withFixedScale(new FixedScaleSettings().withTargetDedicatedNodes(2).withTargetLowPriorityNodes(0)))
.withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC)
.withAutomaticOSUpgradePolicy(new AutomaticOSUpgradePolicy().withEnableAutomaticOSUpgrade(true)))
.create();
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.batch import BatchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-batch
# USAGE
python pool_create_virtual_machine_configuration_service_artifact_reference.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BatchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.pool.create(
resource_group_name="default-azurebatch-japaneast",
account_name="sampleacct",
pool_name="testpool",
parameters={
"properties": {
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest",
},
"nodeAgentSkuId": "batch.node.windows amd64",
"serviceArtifactReference": {
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"
},
"windowsConfiguration": {"enableAutomaticUpdates": False},
}
},
"scaleSettings": {"fixedScale": {"targetDedicatedNodes": 2, "targetLowPriorityNodes": 0}},
"upgradePolicy": {"automaticOSUpgradePolicy": {"enableAutomaticOSUpgrade": True}, "mode": "automatic"},
"vmSize": "Standard_d4s_v3",
}
},
)
print(response)
# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbatch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/batch/armbatch/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e79d9ef3e065f2dcb6bd1db51e29c62a99dff5cb/specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json
func ExamplePoolClient_Create_createPoolVirtualMachineConfigurationServiceArtifactReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbatch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewPoolClient().Create(ctx, "default-azurebatch-japaneast", "sampleacct", "testpool", armbatch.Pool{
Properties: &armbatch.PoolProperties{
DeploymentConfiguration: &armbatch.DeploymentConfiguration{
VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
ImageReference: &armbatch.ImageReference{
Offer: to.Ptr("WindowsServer"),
Publisher: to.Ptr("MicrosoftWindowsServer"),
SKU: to.Ptr("2019-datacenter-smalldisk"),
Version: to.Ptr("latest"),
},
NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
ServiceArtifactReference: &armbatch.ServiceArtifactReference{
ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"),
},
WindowsConfiguration: &armbatch.WindowsConfiguration{
EnableAutomaticUpdates: to.Ptr(false),
},
},
},
ScaleSettings: &armbatch.ScaleSettings{
FixedScale: &armbatch.FixedScaleSettings{
TargetDedicatedNodes: to.Ptr[int32](2),
TargetLowPriorityNodes: to.Ptr[int32](0),
},
},
UpgradePolicy: &armbatch.UpgradePolicy{
AutomaticOSUpgradePolicy: &armbatch.AutomaticOSUpgradePolicy{
EnableAutomaticOSUpgrade: to.Ptr(true),
},
Mode: to.Ptr(armbatch.UpgradeModeAutomatic),
},
VMSize: to.Ptr("Standard_d4s_v3"),
},
}, &armbatch.PoolClientCreateOptions{IfMatch: nil,
IfNoneMatch: nil,
})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Pool = armbatch.Pool{
// Name: to.Ptr("mypool41"),
// Type: to.Ptr("Microsoft.Batch/batchAccounts/pools"),
// Etag: to.Ptr("W/\"0x8DB51F396992B8D\""),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool"),
// Properties: &armbatch.PoolProperties{
// AllocationState: to.Ptr(armbatch.AllocationStateResizing),
// AllocationStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T07:44:44.858Z"); return t}()),
// CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T07:44:44.858Z"); return t}()),
// CurrentDedicatedNodes: to.Ptr[int32](0),
// CurrentLowPriorityNodes: to.Ptr[int32](0),
// DeploymentConfiguration: &armbatch.DeploymentConfiguration{
// VirtualMachineConfiguration: &armbatch.VirtualMachineConfiguration{
// ImageReference: &armbatch.ImageReference{
// Offer: to.Ptr("WindowsServer"),
// Publisher: to.Ptr("MicrosoftWindowsServer"),
// SKU: to.Ptr("2019-datacenter-smalldisk"),
// Version: to.Ptr("latest"),
// },
// NodeAgentSKUID: to.Ptr("batch.node.windows amd64"),
// ServiceArtifactReference: &armbatch.ServiceArtifactReference{
// ID: to.Ptr("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"),
// },
// WindowsConfiguration: &armbatch.WindowsConfiguration{
// EnableAutomaticUpdates: to.Ptr(false),
// },
// },
// },
// InterNodeCommunication: to.Ptr(armbatch.InterNodeCommunicationStateDisabled),
// LastModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T07:44:44.858Z"); return t}()),
// ProvisioningState: to.Ptr(armbatch.PoolProvisioningStateSucceeded),
// ProvisioningStateTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T07:44:44.858Z"); return t}()),
// ResizeOperationStatus: &armbatch.ResizeOperationStatus{
// NodeDeallocationOption: to.Ptr(armbatch.ComputeNodeDeallocationOptionRequeue),
// ResizeTimeout: to.Ptr("PT15M"),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-11T07:44:44.858Z"); return t}()),
// TargetDedicatedNodes: to.Ptr[int32](2),
// },
// ScaleSettings: &armbatch.ScaleSettings{
// FixedScale: &armbatch.FixedScaleSettings{
// ResizeTimeout: to.Ptr("PT15M"),
// TargetDedicatedNodes: to.Ptr[int32](2),
// TargetLowPriorityNodes: to.Ptr[int32](0),
// },
// },
// TaskSchedulingPolicy: &armbatch.TaskSchedulingPolicy{
// NodeFillType: to.Ptr(armbatch.ComputeNodeFillTypeSpread),
// },
// TaskSlotsPerNode: to.Ptr[int32](1),
// UpgradePolicy: &armbatch.UpgradePolicy{
// AutomaticOSUpgradePolicy: &armbatch.AutomaticOSUpgradePolicy{
// EnableAutomaticOSUpgrade: to.Ptr(true),
// },
// Mode: to.Ptr(armbatch.UpgradeModeAutomatic),
// },
// VMSize: to.Ptr("STANDARD_D4S_V3"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BatchManagementClient } = require("@azure/arm-batch");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new pool inside the specified account.
*
* @summary Creates a new pool inside the specified account.
* x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json
*/
async function createPoolVirtualMachineConfigurationServiceArtifactReference() {
const subscriptionId = process.env["BATCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["BATCH_RESOURCE_GROUP"] || "default-azurebatch-japaneast";
const accountName = "sampleacct";
const poolName = "testpool";
const parameters = {
deploymentConfiguration: {
virtualMachineConfiguration: {
imageReference: {
offer: "WindowsServer",
publisher: "MicrosoftWindowsServer",
sku: "2019-datacenter-smalldisk",
version: "latest",
},
nodeAgentSkuId: "batch.node.windows amd64",
serviceArtifactReference: {
id: "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile",
},
windowsConfiguration: { enableAutomaticUpdates: false },
},
},
scaleSettings: {
fixedScale: { targetDedicatedNodes: 2, targetLowPriorityNodes: 0 },
},
upgradePolicy: {
automaticOSUpgradePolicy: { enableAutomaticOSUpgrade: true },
mode: "automatic",
},
vmSize: "Standard_d4s_v3",
};
const credential = new DefaultAzureCredential();
const client = new BatchManagementClient(credential, subscriptionId);
const result = await client.poolOperations.create(
resourceGroupName,
accountName,
poolName,
parameters,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Batch.Models;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Batch;
// Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json
// this example is just showing the usage of "Pool_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BatchAccountResource created on azure
// for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource
string subscriptionId = "subid";
string resourceGroupName = "default-azurebatch-japaneast";
string accountName = "sampleacct";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// invoke the operation
string poolName = "testpool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
VmSize = "Standard_d4s_v3",
DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2019-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64")
{
IsAutomaticUpdateEnabled = false,
ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"),
},
ScaleSettings = new BatchAccountPoolScaleSettings()
{
FixedScale = new BatchAccountFixedScaleSettings()
{
TargetDedicatedNodes = 2,
TargetLowPriorityNodes = 0,
},
},
UpgradePolicy = new UpgradePolicy(UpgradeMode.Automatic)
{
AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy()
{
EnableAutomaticOSUpgrade = true,
},
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BatchAccountPoolData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
ETag: W/"0x8DB51F14DC1A8AD"
{
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool",
"name": "mypool41",
"type": "Microsoft.Batch/batchAccounts/pools",
"etag": "W/\"0x8DB51F396992B8D\"",
"properties": {
"lastModified": "2023-05-11T07:44:44.8580493Z",
"creationTime": "2023-05-11T07:44:44.8580493Z",
"provisioningState": "Succeeded",
"provisioningStateTransitionTime": "2023-05-11T07:44:44.8580493Z",
"allocationState": "Resizing",
"allocationStateTransitionTime": "2023-05-11T07:44:44.8580493Z",
"vmSize": "STANDARD_D4S_V3",
"interNodeCommunication": "Disabled",
"taskSlotsPerNode": 1,
"taskSchedulingPolicy": {
"nodeFillType": "Spread"
},
"deploymentConfiguration": {
"virtualMachineConfiguration": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-datacenter-smalldisk",
"version": "latest"
},
"nodeAgentSkuId": "batch.node.windows amd64",
"windowsConfiguration": {
"enableAutomaticUpdates": false
},
"serviceArtifactReference": {
"id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"
}
}
},
"scaleSettings": {
"fixedScale": {
"targetDedicatedNodes": 2,
"targetLowPriorityNodes": 0,
"resizeTimeout": "PT15M"
}
},
"resizeOperationStatus": {
"targetDedicatedNodes": 2,
"nodeDeallocationOption": "Requeue",
"resizeTimeout": "PT15M",
"startTime": "2023-05-11T07:44:44.8580493Z"
},
"currentDedicatedNodes": 0,
"currentLowPriorityNodes": 0,
"upgradePolicy": {
"mode": "automatic",
"automaticOSUpgradePolicy": {
"enableAutomaticOSUpgrade": true
}
}
}
}
定义
AllocationState
池是否调整大小。
名称 |
类型 |
说明 |
Resizing
|
string
|
池正在调整大小;也就是说,正在向池中添加或删除计算节点。
|
Steady
|
string
|
池未调整大小。 不会更改池中正在进行的节点数。 池在创建时以及池上未执行任何操作以更改节点数时进入此状态。
|
Stopping
|
string
|
池正在调整大小,但用户已请求停止调整大小,但尚未完成停止请求。
|
ApplicationPackageReference
链接到批处理帐户中的应用程序包
名称 |
类型 |
说明 |
id
|
string
|
要安装的应用程序包的 ID。 这必须与池位于同一批处理帐户内。 这可以是对特定版本的引用,也可以是默认版本(如果存在)。
|
version
|
string
|
要部署的应用程序的版本。 如果省略,则部署默认版本。
如果省略此项,并且没有为此应用程序指定默认版本,则请求将失败,错误代码 InvalidApplicationPackageReferences。 如果直接调用 REST API,则 HTTP 状态代码为 409。
|
AutomaticOSUpgradePolicy
用于执行自动 OS 升级的配置参数。
名称 |
类型 |
说明 |
disableAutomaticRollback
|
boolean
|
是否应禁用 OS 映像回滚功能。
|
enableAutomaticOSUpgrade
|
boolean
|
指示当较新版本的 OS 映像可用时,是否应以滚动方式自动将 OS 升级应用于规模集实例。
如果对于基于 Windows 的池,WindowsConfiguration.enableAutomaticUpdates 不能设置为 true。
|
osRollingUpgradeDeferral
|
boolean
|
如果 OS 升级正在运行任务,请延迟 TVM 上的 OS 升级。
|
useRollingUpgradePolicy
|
boolean
|
指示是否应在自动 OS 升级期间使用滚动升级策略。 如果未在 VMSS 上定义任何策略,则自动 OS 升级将回退到默认策略。
|
AutoScaleRun
池自动缩放公式执行的结果和错误。
名称 |
类型 |
说明 |
error
|
AutoScaleRunError
|
如果评估失败,在池中评估自动缩放公式时遇到错误的详细信息。
|
evaluationTime
|
string
|
上次计算自动缩放公式的时间。
|
results
|
string
|
自动缩放公式计算中使用的所有变量的最终值。
每个变量值以 $variable=value 的形式返回,变量由分号分隔。
|
AutoScaleRunError
自动缩放池时发生的错误。
名称 |
类型 |
说明 |
code
|
string
|
错误的标识符。 代码是固定的,旨在以编程方式使用。
|
details
|
AutoScaleRunError[]
|
有关错误的其他详细信息。
|
message
|
string
|
描述错误的消息,旨在适合在用户界面中显示。
|
AutoScaleSettings
池的自动缩放设置。
名称 |
类型 |
说明 |
evaluationInterval
|
string
|
根据自动缩放公式自动调整池大小的时间间隔。
如果省略,则默认值为 15 分钟(PT15M)。
|
formula
|
string
|
池中所需计算节点数的公式。
|
AutoUserScope
自动用户的范围
名称 |
类型 |
说明 |
Pool
|
string
|
指定任务作为在池中的每个节点上创建的通用自动用户帐户运行。
|
Task
|
string
|
指定服务应为任务创建新用户。
|
AutoUserSpecification
指定在 Batch 服务上运行任务的自动用户的参数。
名称 |
类型 |
说明 |
elevationLevel
|
ElevationLevel
|
自动用户的提升级别。
默认值为 nonAdmin。
|
scope
|
AutoUserScope
|
自动用户的范围
默认值为 Pool。 如果池正在运行 Windows,则应指定任务值(如果需要在任务之间进行更严格的隔离)。 例如,如果任务以可能影响其他任务的方式改变注册表,或者已在池中指定了证书,而正常任务不应可访问,但应可通过启动任务访问。
|
AzureBlobFileSystemConfiguration
用于使用 Blobfuse 连接到 Azure 存储容器的信息。
名称 |
类型 |
说明 |
accountKey
|
string
|
Azure 存储帐户密钥。
此属性与 sasKey 和标识互斥;必须指定一个。
|
accountName
|
string
|
Azure 存储帐户名称。
|
blobfuseOptions
|
string
|
要传递给装载命令的其他命令行选项。
这些是 Windows 中的“net use”选项,Linux 中的“装载”选项。
|
containerName
|
string
|
Azure Blob 存储容器名称。
|
identityReference
|
ComputeNodeIdentityReference
|
对用于访问 containerName 的用户分配标识的引用
此属性与 accountKey 和 sasKey 互斥;必须指定一个。
|
relativeMountPath
|
string
|
将装载文件系统的计算节点上的相对路径
所有文件系统都相对于 Batch 装载目录进行装载,可通过AZ_BATCH_NODE_MOUNTS_DIR环境变量进行访问。
|
sasKey
|
string
|
Azure 存储 SAS 令牌。
此属性与 accountKey 和 identity 互斥;必须指定一个。
|
AzureFileShareConfiguration
用于连接到 Azure 文件共享的信息。
名称 |
类型 |
说明 |
accountKey
|
string
|
Azure 存储帐户密钥。
|
accountName
|
string
|
Azure 存储帐户名称。
|
azureFileUrl
|
string
|
Azure 文件 URL。
此格式为“https://{account}.file.core.windows.net/”。
|
mountOptions
|
string
|
要传递给装载命令的其他命令行选项。
这些是 Windows 中的“net use”选项,Linux 中的“装载”选项。
|
relativeMountPath
|
string
|
将装载文件系统的计算节点上的相对路径
所有文件系统都相对于 Batch 装载目录进行装载,可通过AZ_BATCH_NODE_MOUNTS_DIR环境变量进行访问。
|
BatchPoolIdentity
Batch 池的标识(如果已配置)。 如果在更新现有池期间更新池标识,则只有池收缩到 0 后创建的新 VM 才会有更新的标识
CachingType
要为磁盘启用的缓存类型。
名称 |
类型 |
说明 |
None
|
string
|
未启用磁盘的缓存模式。
|
ReadOnly
|
string
|
磁盘的缓存模式是只读的。
|
ReadWrite
|
string
|
磁盘的缓存模式是读取和写入的。
|
CertificateReference
对要安装在池中的计算节点上的证书的引用。 这必须与池位于同一帐户内。
名称 |
类型 |
说明 |
id
|
string
|
要安装在池中的证书的完全限定 ID。 这必须与池位于同一批处理帐户内。
|
storeLocation
|
CertificateStoreLocation
|
要在其中安装证书的计算节点上的证书存储位置。
默认值为 currentUser。 此属性仅适用于使用 Windows 计算节点配置的池。 对于 Linux 计算节点,证书存储在任务工作目录中的目录中,并向任务提供环境变量AZ_BATCH_CERTIFICATES_DIR以查询此位置。 对于可见性为“remoteUser”的证书,将在用户的主目录中(例如 /home/{user-name}/certs)中创建一个“certs”目录,并将证书置于该目录中。
|
storeName
|
string
|
要在其中安装证书的计算节点上的证书存储的名称。
此属性仅适用于使用 Windows 计算节点配置的池。 常见的存储名称包括:My、Root、CA、Trust、Trustallowed、TrustedPeople、TrustedPublisher、AuthRoot、AddressBook,但也可以使用任何自定义存储名称。 默认值为“我的”。
|
visibility
|
CertificateVisibility[]
|
计算节点上的哪些用户帐户应有权访问证书的专用数据。
|
CertificateStoreLocation
要在其中安装证书的计算节点上的证书存储位置。
名称 |
类型 |
说明 |
CurrentUser
|
string
|
证书应安装到 CurrentUser 证书存储。
|
LocalMachine
|
string
|
证书应安装到 LocalMachine 证书存储。
|
CertificateVisibility
计算节点上的哪些用户帐户应有权访问证书的专用数据。
名称 |
类型 |
说明 |
RemoteUser
|
string
|
证书应该对用户远程访问节点的用户帐户可见。
|
StartTask
|
string
|
证书应该对运行启动任务的用户帐户可见。 请注意,如果 AutoUser 作用域是 StartTask 和 Task 的池,则此证书也将对任务可见。
|
Task
|
string
|
证书应该对运行作业任务的用户帐户可见。
|
CIFSMountConfiguration
用于连接到 CIFS 文件系统的信息。
名称 |
类型 |
说明 |
mountOptions
|
string
|
要传递给装载命令的其他命令行选项。
这些是 Windows 中的“net use”选项,Linux 中的“装载”选项。
|
password
|
string
|
用于针对 CIFS 文件系统进行身份验证的密码。
|
relativeMountPath
|
string
|
将装载文件系统的计算节点上的相对路径
所有文件系统都相对于 Batch 装载目录进行装载,可通过AZ_BATCH_NODE_MOUNTS_DIR环境变量进行访问。
|
source
|
string
|
要装载的文件系统的 URI。
|
userName
|
string
|
用于对 CIFS 文件系统进行身份验证的用户。
|
CloudError
Batch 服务的错误响应。
CloudErrorBody
Batch 服务的错误响应。
名称 |
类型 |
说明 |
code
|
string
|
错误的标识符。 代码是固定的,旨在以编程方式使用。
|
details
|
CloudErrorBody[]
|
有关错误的其他详细信息的列表。
|
message
|
string
|
描述错误的消息,旨在适合在用户界面中显示。
|
target
|
string
|
特定错误的目标。 例如,错误属性的名称。
|
ComputeNodeDeallocationOption
确定在为解除分配选择节点后如何处理节点及其正在运行的任务。
名称 |
类型 |
说明 |
Requeue
|
string
|
终止正在运行的任务进程并重新排队任务。 当节点可用时,任务将再次运行。 在任务终止后立即删除节点。
|
RetainedData
|
string
|
允许当前运行的任务完成,然后等待所有任务数据保留期到期。 等待时不安排新任务。 删除所有任务保留期已过期的节点。
|
TaskCompletion
|
string
|
允许当前运行的任务完成。 等待时不安排新任务。 完成所有任务后,删除节点。
|
Terminate
|
string
|
终止正在运行的任务。 任务将在 failureInfo 中完成,指示它们已终止,并且不会再次运行。 在任务终止后立即删除节点。
|
ComputeNodeFillType
如何跨计算节点分配任务。
名称 |
类型 |
说明 |
Pack
|
string
|
在将任何任务分配到池中的下一个节点之前,应向池中的每个节点分配尽可能多的任务(taskSlotsPerNode)。
|
Spread
|
string
|
应跨池中的所有节点均匀分配任务。
|
ComputeNodeIdentityReference
对与计算节点将使用的 Batch 池关联的用户分配标识的引用。
名称 |
类型 |
说明 |
resourceId
|
string
|
用户分配标识的 ARM 资源 ID。
|
ContainerConfiguration
已启用容器的池的配置。
名称 |
类型 |
说明 |
containerImageNames
|
string[]
|
容器映像名称的集合。
这是完整的映像引用,如指定为“docker pull”。 除非映像使用备用注册表完全限定映像,否则映像将源自默认 Docker 注册表。
|
containerRegistries
|
ContainerRegistry[]
|
可从中提取容器的其他专用注册表。
如果必须从需要凭据的专用注册表下载任何映像,则必须在此处提供这些凭据。
|
type
|
ContainerType
|
要使用的容器技术。
|
ContainerHostBatchBindMountEntry
要装载到任务容器的路径和装载模式的条目。
名称 |
类型 |
说明 |
isReadOnly
|
boolean
|
将此源路径装载为只读模式或不装载。 默认值为 false(读/写模式)。
对于 Linux,如果将此路径装载为读/写模式,这并不意味着容器中的所有用户都具有路径的读/写访问权限,这取决于主机 VM 中的访问。 如果此路径装载为只读,则容器中的所有用户将无法修改路径。
|
source
|
ContainerHostDataPath
|
装载到容器客户的路径可以选择。
|
ContainerHostDataPath
将装载到容器任务的容器的路径。
名称 |
类型 |
说明 |
Applications
|
string
|
应用程序路径。
|
JobPrep
|
string
|
作业准备任务路径。
|
Shared
|
string
|
用于共享其文件的多实例任务的路径。
|
Startup
|
string
|
启动任务的路径。
|
Task
|
string
|
任务路径。
|
VfsMounts
|
string
|
该路径包含此节点上装载的所有虚拟文件系统。
|
ContainerRegistry
专用容器注册表。
名称 |
类型 |
说明 |
identityReference
|
ComputeNodeIdentityReference
|
对用于访问 Azure 容器注册表(而不是用户名和密码)的用户分配标识的引用。
对与计算节点将使用的 Batch 池关联的用户分配标识的引用。
|
password
|
string
|
登录到注册表服务器的密码。
|
registryServer
|
string
|
注册表 URL。
如果省略,则默认值为“docker.io”。
|
username
|
string
|
要登录到注册表服务器的用户名。
|
ContainerType
要使用的容器技术。
名称 |
类型 |
说明 |
CriCompatible
|
string
|
基于 CRI 的技术将用于启动容器。
|
DockerCompatible
|
string
|
Docker 兼容的容器技术将用于启动容器。
|
ContainerWorkingDirectory
用于指示容器任务工作目录所在的位置的标志。 默认值为“taskWorkingDirectory”。
名称 |
类型 |
说明 |
ContainerImageDefault
|
string
|
使用容器映像定义的工作目录。 请注意,此目录将不包含 Batch 下载的资源文件。
|
TaskWorkingDirectory
|
string
|
使用标准 Batch 服务任务工作目录,其中包含 Batch 填充的任务资源文件。
|
DataDisk
与池中的计算节点关联的数据磁盘将使用的设置。 使用附加的数据磁盘时,需要从 VM 中装载磁盘并设置磁盘格式才能使用这些磁盘。
DeploymentConfiguration
部署配置属性。
DiffDiskPlacement
指定池中所有 VM 的操作系统磁盘的临时磁盘放置。
名称 |
类型 |
说明 |
CacheDisk
|
string
|
临时 OS 磁盘存储在 VM 缓存中。
|
DiffDiskSettings
指定虚拟机使用的操作系统磁盘的临时磁盘设置。
DiskEncryptionConfiguration
在池中的计算节点上应用的磁盘加密配置。 使用虚拟机映像或 Azure 计算库映像创建的 Linux 池不支持磁盘加密配置。
名称 |
类型 |
说明 |
targets
|
DiskEncryptionTarget[]
|
Batch 服务将在计算节点上加密的磁盘目标列表
在 Linux 池中,仅支持“TemporaryDisk”;在 Windows 池中,必须指定“OsDisk”和“TemporaryDisk”。
|
DiskEncryptionTarget
Batch 服务将在计算节点上加密的磁盘目标列表
名称 |
类型 |
说明 |
OsDisk
|
string
|
计算节点上的 OS 磁盘已加密。
|
TemporaryDisk
|
string
|
计算节点上的临时磁盘已加密。 在 Linux 上,此加密适用于在启动时进行加密时的其他分区(例如装载的数据磁盘上的分区)。
|
DynamicVNetAssignmentScope
动态 vnet 分配的范围。
名称 |
类型 |
说明 |
job
|
string
|
动态 VNet 分配按作业完成。 如果设置了此值,还必须设置网络配置子网 ID。 此功能需要在使用前获得批准,请联系支持人员
|
none
|
string
|
未启用动态 VNet 分配。
|
ElevationLevel
用户的提升级别。
名称 |
类型 |
说明 |
Admin
|
string
|
用户是具有提升访问权限并具有完全管理员权限的用户。
|
NonAdmin
|
string
|
用户是没有提升访问权限的标准用户。
|
EnvironmentSetting
要对任务进程设置的环境变量。
名称 |
类型 |
说明 |
name
|
string
|
环境变量的名称。
|
value
|
string
|
环境变量的值。
|
FixedScaleSettings
修复了池的缩放设置。
名称 |
类型 |
默认值 |
说明 |
nodeDeallocationOption
|
ComputeNodeDeallocationOption
|
|
确定节点及其正在运行的任务(如果池大小正在减少)执行的操作。
如果省略,则默认值为“重新排队”。
|
resizeTimeout
|
string
|
PT15M
|
将计算节点分配给池的超时。
默认值为 15 分钟。 超时值使用 ISO 8601 格式。 例如,使用 PT10M 10 分钟。 最小值为 5 分钟。 如果指定的值小于 5 分钟,Batch 服务将拒绝请求并显示错误;如果直接调用 REST API,则 HTTP 状态代码为 400(请求错误)。
|
targetDedicatedNodes
|
integer
|
|
池中所需的专用计算节点数。
必须设置至少一个 targetDedicatedNodes,targetLowPriorityNodes。
|
targetLowPriorityNodes
|
integer
|
|
池中所需的现成/低优先级计算节点数。
必须设置至少一个 targetDedicatedNodes,targetLowPriorityNodes。
|
ImageReference
对 Azure 虚拟机市场映像或自定义虚拟机的 Azure 映像资源的引用。 若要获取 Azure Batch 验证的所有 imageReference 的列表,请参阅“列出支持的节点代理 SKU”操作。
名称 |
类型 |
说明 |
communityGalleryImageId
|
string
|
社区库映像唯一标识符
此属性与其他属性互斥,可以从社区库映像 GET 调用中提取。
|
id
|
string
|
Azure 计算库映像的 ARM 资源标识符。 池中的计算节点将使用此映像 ID 创建。此格式为 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/gallerys/{galleryName}/images/{imageDefinitionName}/versions/{versionId}。
此属性与其他属性互斥。 Azure 计算库映像必须与 Azure Batch 帐户位于同一区域中的副本。 有关 Batch 节点代理与 Batch 服务通信的防火墙设置的信息,请参阅 https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration。
|
offer
|
string
|
Azure 虚拟机市场映像的产品/服务类型。
例如,UbuntuServer 或 WindowsServer。
|
publisher
|
string
|
Azure 虚拟机市场映像的发布者。
例如,Canonical 或 MicrosoftWindowsServer。
|
sharedGalleryImageId
|
string
|
共享库映像唯一标识符
此属性与其他属性互斥,可以从共享库映像 GET 调用中提取。
|
sku
|
string
|
Azure 虚拟机市场映像的 SKU。
例如,18.04-LTS 或 2022 数据中心。
|
version
|
string
|
Azure 虚拟机市场映像的版本。
可以指定值“latest”以选择映像的最新版本。 如果省略,则默认值为“latest”。
|
InboundEndpointProtocol
终结点的协议。
名称 |
类型 |
说明 |
TCP
|
string
|
对终结点使用 TCP。
|
UDP
|
string
|
对终结点使用 UDP。
|
InboundNatPool
入站 NAT 池,可用于在外部处理 Batch 池中计算节点上的特定端口。
名称 |
类型 |
说明 |
backendPort
|
integer
|
计算节点上的端口号。
这在 Batch 池中必须是唯一的。 可接受的值介于 1 和 65535 之间,但 29876 和 29877 除外,因为这些值是保留的。 如果提供任何保留值,则请求失败并显示 HTTP 状态代码 400。
|
frontendPortRangeEnd
|
integer
|
外部端口范围中的最后一个端口号,用于在单个计算节点上提供对 backendPort 的入站访问。
可接受的值介于 1 到 65534 之间,但 Batch 服务保留的端口范围为 50000 到 55000。 池中的所有范围都必须是不同的,并且不能重叠。 如果提供任何保留值或重叠值,则请求失败并显示 HTTP 状态代码 400。
|
frontendPortRangeStart
|
integer
|
外部端口范围中的第一个端口号,用于在单个计算节点上提供对 backendPort 的入站访问。
可接受的值介于 1 到 65534 之间,但保留的端口范围为 50000 到 55000。 池中的所有范围都必须是不同的,并且不能重叠。 如果提供任何保留值或重叠值,则请求失败并显示 HTTP 状态代码 400。
|
name
|
string
|
终结点的名称。
名称在 Batch 池中必须唯一,可以包含字母、数字、下划线、句点和连字符。 名称必须以字母或数字开头,必须以字母、数字或下划线结尾,并且不能超过 77 个字符。 如果提供任何无效值,则请求失败并显示 HTTP 状态代码 400。
|
networkSecurityGroupRules
|
NetworkSecurityGroupRule[]
|
将应用于终结点的网络安全组规则列表。
可以在 Batch 池的所有终结点上指定的最大规则数为 25。 如果未指定网络安全组规则,则会创建默认规则以允许对指定的 backendPort 进行入站访问。 如果超过网络安全组规则的最大数目,则请求失败并显示 HTTP 状态代码 400。
|
protocol
|
InboundEndpointProtocol
|
终结点的协议。
|
InterNodeCommunicationState
池是否允许在节点之间直接通信。
名称 |
类型 |
说明 |
Disabled
|
string
|
禁用虚拟机之间的网络通信。
|
Enabled
|
string
|
启用虚拟机之间的网络通信。
|
IPAddressProvisioningType
Batch 池的公共 IP 地址的预配类型。
名称 |
类型 |
说明 |
BatchManaged
|
string
|
公共 IP 将由 Batch 创建和管理。 可能有多个公共 IP,具体取决于池的大小。
|
NoPublicIPAddresses
|
string
|
不会为池中的计算节点创建公共 IP 地址。
|
UserManaged
|
string
|
公共 IP 由用户提供,用于预配计算节点。
|
LinuxUserConfiguration
用于在 Linux 节点上创建用户帐户的属性。
名称 |
类型 |
说明 |
gid
|
integer
|
用户帐户的组 ID。
uid 和 gid 属性必须同时指定或根本不指定。 如果未指定基础操作系统,则选取 gid。
|
sshPrivateKey
|
string
|
用户帐户的 SSH 私钥。
私钥不得受密码保护。 当池的 enableInterNodeCommunication 属性为 true 时,私钥用于在 Linux 池中的节点之间自动配置基于非对称密钥的身份验证(如果 enableInterNodeCommunication 为 false,则忽略该身份验证)。 它通过将密钥对放入用户的 .ssh 目录来执行此操作。 如果未指定,则节点之间未配置无密码 SSH(未修改用户的 .ssh 目录)。
|
uid
|
integer
|
用户帐户的用户 ID。
uid 和 gid 属性必须同时指定或根本不指定。 如果未指定基础操作系统,则选取 uid。
|
LoginMode
用户的登录模式
名称 |
类型 |
说明 |
Batch
|
string
|
LOGON32_LOGON_BATCH Win32 登录模式。 对于长时间运行的并行进程,建议使用批处理登录模式。
|
Interactive
|
string
|
LOGON32_LOGON_INTERACTIVE Win32 登录模式。 某些应用程序需要具有与交互式登录模式关联的权限。 如果这是任务中使用的应用程序的情况,则建议使用此选项。
|
ManagedDisk
与 Batch 服务资源关联的名称/值对。
名称 |
类型 |
说明 |
name
|
string
|
元数据项的名称。
|
value
|
string
|
元数据项的值。
|
MountConfiguration
要在每个节点上装载的文件系统。
NetworkConfiguration
池的网络配置。
NetworkSecurityGroupRule
要应用于入站终结点的网络安全组规则。
名称 |
类型 |
说明 |
access
|
NetworkSecurityGroupRuleAccess
|
应对指定 IP 地址、子网范围或标记执行的操作。
|
priority
|
integer
|
此规则的优先级。
池中的优先级必须是唯一的,并且按优先级顺序进行评估。 优先级越高的数字越低。 例如,可以使用订单号 150、250 和 350 指定规则。 顺序编号为 150 的规则优先于顺序为 250 的规则。 允许的优先级为 150 到 4096。 如果提供了任何保留值或重复值,则请求失败并显示 HTTP 状态代码 400。
|
sourceAddressPrefix
|
string
|
要匹配规则的源地址前缀或标记。
有效值为单个 IP 地址(即 10.10.10.10)、IP 子网(即 192.168.1.0/24)、默认标记或 * (适用于所有地址)。 如果提供了任何其他值,请求将失败并显示 HTTP 状态代码 400。
|
sourcePortRanges
|
string[]
|
要匹配规则的源端口范围。
有效值为“*”(对于所有端口 0 - 65535)或端口或端口范围的数组(即 100-200)。 端口应介于 0 到 65535 的范围内,端口范围或端口不能重叠。 如果提供了任何其他值,请求将失败并显示 HTTP 状态代码 400。 默认值为 *。
|
NetworkSecurityGroupRuleAccess
应对指定 IP 地址、子网范围或标记执行的操作。
名称 |
类型 |
说明 |
Allow
|
string
|
允许访问。
|
Deny
|
string
|
拒绝访问。
|
NFSMountConfiguration
用于连接到 NFS 文件系统的信息。
名称 |
类型 |
说明 |
mountOptions
|
string
|
要传递给装载命令的其他命令行选项。
这些是 Windows 中的“net use”选项,Linux 中的“装载”选项。
|
relativeMountPath
|
string
|
将装载文件系统的计算节点上的相对路径
所有文件系统都相对于 Batch 装载目录进行装载,可通过AZ_BATCH_NODE_MOUNTS_DIR环境变量进行访问。
|
source
|
string
|
要装载的文件系统的 URI。
|
NodeCommunicationMode
确定池如何与 Batch 服务通信。
名称 |
类型 |
说明 |
Classic
|
string
|
使用经典通信模式的节点需要在端口 29876 和 29877 上通过“BatchNodeManagement”进行入站 TCP 通信。{region}“ 服务标记和端口 443 上的出站 TCP 通信到”Storage.region“和”BatchNodeManagement”。{region}“ 服务标记。
|
Default
|
string
|
节点通信模式由 Batch 服务自动设置。
|
Simplified
|
string
|
使用简化通信模式的节点需要在端口 443 上与“BatchNodeManagement”进行出站 TCP 通信。{region}“ 服务标记。 不需要打开的入站端口。
|
NodePlacementConfiguration
批处理池的节点放置配置。
NodePlacementPolicyType
用于分配池中的节点的放置策略。
名称 |
类型 |
说明 |
Regional
|
string
|
池中的所有节点都将在同一区域中分配。
|
Zonal
|
string
|
池中的节点将分布在不同区域,并尽最大努力进行平衡。
|
OSDisk
虚拟机操作系统磁盘的设置。
名称 |
类型 |
说明 |
caching
|
CachingType
|
指定缓存要求。 可能的值包括:None、ReadOnly、ReadWrite。 默认值为:标准存储无。 高级存储的 ReadOnly。
|
diskSizeGB
|
integer
|
创建新 OS 磁盘时的初始磁盘大小(以 GB 为单位)。
|
ephemeralOSDiskSettings
|
DiffDiskSettings
|
指定虚拟机使用的操作系统磁盘的临时磁盘设置。
|
managedDisk
|
ManagedDisk
|
托管磁盘参数。
|
writeAcceleratorEnabled
|
boolean
|
指定是应在磁盘上启用或禁用 writeAccelerator。
|
Pool
包含有关池的信息。
名称 |
类型 |
默认值 |
说明 |
etag
|
string
|
|
资源的 ETag,用于并发语句。
|
id
|
string
|
|
资源的 ID。
|
identity
|
BatchPoolIdentity
|
|
用于 Batch 池的标识类型。
用于 Batch 池的标识类型。
|
name
|
string
|
|
资源的名称。
|
properties.allocationState
|
AllocationState
|
|
池是否调整大小。
|
properties.allocationStateTransitionTime
|
string
|
|
池进入其当前分配状态的时间。
|
properties.applicationLicenses
|
string[]
|
|
Batch 服务将在池中的每个计算节点上可用的应用程序许可证列表。
应用程序许可证列表必须是可用 Batch 服务应用程序许可证的子集。 如果请求的许可证不受支持,则池创建将失败。
|
properties.applicationPackages
|
ApplicationPackageReference[]
|
|
要安装在池中每个计算节点上的应用程序包的列表。
对应用程序包引用的更改会影响所有加入池的新计算节点,但在重新启动或重新映像之前,不会影响池中已有的计算节点。 任何给定池上最多有 10 个应用程序包引用。
|
properties.autoScaleRun
|
AutoScaleRun
|
|
自动缩放公式上次执行的结果和错误。
仅当池自动缩放(即使用 autoScaleSettings)时,才会设置此属性。
|
properties.certificates
|
CertificateReference[]
|
|
要安装在池中每个计算节点上的证书列表。
对于 Windows 计算节点,Batch 服务会将证书安装到指定的证书存储和位置。 对于 Linux 计算节点,证书存储在任务工作目录中的目录中,并向任务提供环境变量AZ_BATCH_CERTIFICATES_DIR以查询此位置。 对于可见性为“remoteUser”的证书,将在用户的主目录中(例如 /home/{user-name}/certs)中创建一个“certs”目录,并将证书置于该目录中。
警告:此属性已弃用,将在 2024 年 2 月之后删除。 请改用 Azure KeyVault 扩展。
|
properties.creationTime
|
string
|
|
池的创建时间。
|
properties.currentDedicatedNodes
|
integer
|
|
池中当前专用计算节点的数目。
|
properties.currentLowPriorityNodes
|
integer
|
|
池中当前存在的现成/低优先级计算节点数。
|
properties.currentNodeCommunicationMode
|
NodeCommunicationMode
|
|
池通信模式的当前状态。
|
properties.deploymentConfiguration
|
DeploymentConfiguration
|
|
此属性描述池节点将部署到的虚拟机。
|
properties.displayName
|
string
|
|
池的显示名称。
显示名称不一定是唯一的,可以包含最大长度为 1024 的任何 Unicode 字符。
|
properties.interNodeCommunication
|
InterNodeCommunicationState
|
|
池是否允许在节点之间直接通信。
这会对可分配给池的节点施加限制。 启用此值可以减少在池中分配请求的节点数的可能性。 如果未指定,则此值默认为“Disabled”。
|
properties.lastModified
|
string
|
|
池的上次修改时间。
这是池级别数据(如 targetDedicatedNodes 或 autoScaleSettings)上次更改的时间。 它不考虑节点级更改,例如计算节点更改状态。
|
properties.metadata
|
MetadataItem[]
|
|
与池关联的名称/值对列表作为元数据。
Batch 服务不向元数据分配任何含义;它仅用于使用用户代码。
|
properties.mountConfiguration
|
MountConfiguration[]
|
|
要安装在池中每个节点上的文件系统列表。
这支持 Azure 文件存储、NFS、CIFS/SMB 和 Blobfuse。
|
properties.networkConfiguration
|
NetworkConfiguration
|
|
池的网络配置。
池的网络配置。
|
properties.provisioningState
|
PoolProvisioningState
|
|
池的当前状态。
|
properties.provisioningStateTransitionTime
|
string
|
|
池进入其当前状态的时间。
|
properties.resizeOperationStatus
|
ResizeOperationStatus
|
|
包含有关当前或上次完成的大小调整操作的详细信息。
描述当前操作(如果池 AllocationState 调整大小)或之前完成的操作(如果 AllocationState 为稳定)。
|
properties.resourceTags
|
object
|
|
与池关联的用户指定的标记。
要与 Azure Batch 池关联的用户定义的标记。 指定后,这些标记将传播到与池关联的支持 Azure 资源。 仅当使用 poolAllocationMode 属性设置为“UserSubscription”创建的 Batch 帐户时,才能指定此属性。
|
properties.scaleSettings
|
ScaleSettings
|
|
配置池中节点数的设置。
定义池的所需大小。 这可以是指定所请求的目标DedicatedNode 的“fixedScale”,也可以是定义定期重新计算的公式的“autoScale”。 如果未指定此属性,则池将具有具有 0 个 targetDedicatedNodes 的固定缩放。
|
properties.startTask
|
StartTask
|
|
指定在联接池时在每个计算节点上运行的任务。
在 PATCH(更新)操作中,此属性可以设置为空对象,以从池中删除启动任务。
|
properties.targetNodeCommunicationMode
|
NodeCommunicationMode
|
|
池的所需节点通信模式。
如果省略,则默认值为 Default。
|
properties.taskSchedulingPolicy
|
TaskSchedulingPolicy
|
|
如何跨池中的计算节点分配任务。
如果未指定,则默认为分散。
|
properties.taskSlotsPerNode
|
integer
|
1
|
可用于在池中的单个计算节点上运行并发任务的任务槽数。
默认值为 1。 最大值是池的 vmSize 核心数或 256 的 4 倍。
|
properties.upgradePolicy
|
UpgradePolicy
|
|
池的升级策略。
描述升级策略 - 自动、手动或滚动。
|
properties.userAccounts
|
UserAccount[]
|
|
将在池中的每个节点上创建的用户帐户列表。
|
properties.vmSize
|
string
|
|
池中虚拟机的大小。 池中的所有 VM 大小相同。
有关可用 VM 大小的信息,请参阅虚拟机(Linux)(https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)或虚拟机(Windows)的大小(https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/)。 Batch 支持除STANDARD_A0和具有高级存储(STANDARD_GS、STANDARD_DS和STANDARD_DSV2系列)之外的所有 Azure VM 大小。
|
tags
|
object
|
|
资源的标记。
|
type
|
string
|
|
资源的类型。
|
PoolEndpointConfiguration
池的终结点配置。
名称 |
类型 |
说明 |
inboundNatPools
|
InboundNatPool[]
|
入站 NAT 池列表,可用于在外部解决单个计算节点上的特定端口。
每个 Batch 池的最大入站 NAT 池数为 5。 如果超出最大入站 NAT 池数,则请求失败并显示 HTTP 状态代码 400。 如果 IPAddressProvisioningType 为 NoPublicIPAddresses,则无法指定此项。
|
PoolIdentityType
用于 Batch 池的标识类型。
名称 |
类型 |
说明 |
None
|
string
|
Batch 池没有与之关联的标识。 在更新池中设置 None 将删除现有标识。
|
UserAssigned
|
string
|
Batch 池具有用户分配的标识。
|
PoolProvisioningState
池的当前状态。
名称 |
类型 |
说明 |
Deleting
|
string
|
用户已请求删除池,但删除操作尚未完成。
|
Succeeded
|
string
|
池可用于运行受计算节点可用性约束的任务。
|
PublicIPAddressConfiguration
池的网络配置的公共 IP 地址配置。
名称 |
类型 |
说明 |
ipAddressIds
|
string[]
|
预配计算节点时 Batch 服务将使用的公共 IP 列表。
此处指定的 IP 数限制池的最大大小 - 可以为每个公共 IP 分配 100 个专用节点或 100 个现成/低优先级节点。 例如,需要 250 个专用 VM 的池至少需要指定 3 个公共 IP。 此集合的每个元素都采用以下形式:/subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}。
|
provision
|
IPAddressProvisioningType
|
池的公共 IP 地址的预配类型
默认值为 BatchManaged
|
ResizeError
调整池大小时发生的错误。
名称 |
类型 |
说明 |
code
|
string
|
错误的标识符。 代码是固定的,旨在以编程方式使用。
|
details
|
ResizeError[]
|
有关错误的其他详细信息。
|
message
|
string
|
描述错误的消息,旨在适合在用户界面中显示。
|
ResizeOperationStatus
有关当前或上次完成的大小调整操作的详细信息。
名称 |
类型 |
说明 |
errors
|
ResizeError[]
|
在池上执行上一次重设大小时遇到的任何错误的详细信息。
仅当上一个池调整大小期间发生错误,并且仅当池 allocationState 为稳定时,才会设置此属性。
|
nodeDeallocationOption
|
ComputeNodeDeallocationOption
|
确定节点及其正在运行的任务(如果池大小正在减少)执行的操作。
默认值为重新排队。
|
resizeTimeout
|
string
|
将计算节点分配给池或从池中删除计算节点的超时。
默认值为 15 分钟。 最小值为 5 分钟。 如果指定的值小于 5 分钟,Batch 服务将返回错误;如果直接调用 REST API,则 HTTP 状态代码为 400(请求错误)。
|
startTime
|
string
|
启动此调整大小操作的时间。
|
targetDedicatedNodes
|
integer
|
池中所需的专用计算节点数。
|
targetLowPriorityNodes
|
integer
|
池中所需的现成/低优先级计算节点数。
|
ResourceFile
要下载到计算节点的单个文件或多个文件。
名称 |
类型 |
说明 |
autoStorageContainerName
|
string
|
自动存储帐户中的存储容器名称。
autoStorageContainerName、storageContainerUrl 和 httpUrl 属性互斥,必须指定其中一个属性。
|
blobPrefix
|
string
|
从 Azure 存储容器下载 Blob 时要使用的 Blob 前缀。 仅下载名称以指定前缀开头的 blob。
仅当使用 autoStorageContainerName 或 storageContainerUrl 时,该属性才有效。 此前缀可以是部分文件名或子目录。 如果未指定前缀,则会下载容器中的所有文件。
|
fileMode
|
string
|
以八进制格式的文件权限模式属性。
此属性仅适用于下载到 Linux 计算节点的文件。 如果为将下载到 Windows 节点的 resourceFile 指定,将忽略它。 如果未为 Linux 节点指定此属性,则将默认值 0770 应用于该文件。
|
filePath
|
string
|
要下载文件的计算节点上相对于任务的工作目录的位置。
如果指定了 httpUrl 属性,则需要 filePath,并描述文件将下载到的路径,包括文件名。 否则,如果指定 autoStorageContainerName 或 storageContainerUrl 属性,则 filePath 是可选的,并且是将文件下载到的目录。 如果 filePath 用作目录,则与输入数据关联的任何目录结构都将完整保留并追加到指定的 filePath 目录。 指定的相对路径不能脱离任务的工作目录(例如,使用'.')。
|
httpUrl
|
string
|
要下载的文件的 URL。
autoStorageContainerName、storageContainerUrl 和 httpUrl 属性互斥,必须指定其中一个属性。 如果 URL 指向 Azure Blob 存储,则必须从计算节点读取该 URL。 可通过三种方法获取 Azure 存储中 Blob 的此类 URL:包括授予对 Blob 的读取权限的共享访问签名(SAS),使用具有读取权限的托管标识,或为 Blob 或其容器设置 ACL 以允许公共访问。
|
identityReference
|
ComputeNodeIdentityReference
|
对用户分配的标识的引用,用于访问由 storageContainerUrl 或 httpUrl 指定的 Azure Blob 存储
对与计算节点将使用的 Batch 池关联的用户分配标识的引用。
|
storageContainerUrl
|
string
|
Azure Blob 存储中 Blob 容器的 URL。
autoStorageContainerName、storageContainerUrl 和 httpUrl 属性互斥,必须指定其中一个属性。 此 URL 必须可从计算节点读取和列出。 可通过三种方法获取 Azure 存储中容器的此类 URL:包括授予对容器的读取和列表权限的共享访问签名(SAS),使用具有读取和列表权限的托管标识,或为容器设置 ACL 以允许公共访问。
|
RollingUpgradePolicy
执行滚动升级时使用的配置参数。
名称 |
类型 |
说明 |
enableCrossZoneUpgrade
|
boolean
|
允许 VMSS 在构造升级批处理时忽略 AZ 边界。 考虑 Update 域和 maxBatchInstancePercent 以确定批大小。 如果未设置此字段,Azure Batch 将不会设置其默认值。 创建的 VirtualMachineScaleSet 上的 enableCrossZoneUpgrade 值将由 VirtualMachineScaleSet 上的默认配置决定。 仅当将 NodePlacementConfiguration 用作 Zonal 时,此字段才可设置为 true 或 false。
|
maxBatchInstancePercent
|
integer
|
一批滚动升级同时升级的总虚拟机实例的最大百分比。 由于这是一个最大值,因此以前的或将来的批中的不正常实例可能会导致批处理中的实例百分比降低,以确保更高的可靠性。 此字段的值应介于 5 和 100 之间(含)。 如果 maxBatchInstancePercent 和 maxUnhealthyInstancePercent 都赋值,则 maxBatchInstancePercent 的值不应大于 maxUnhealthyInstancePercent。
|
maxUnhealthyInstancePercent
|
integer
|
规模集中可能同时运行不正常的虚拟机实例的最大百分比,无论是由于升级,还是虚拟机运行状况检查在滚动升级中止之前处于不正常状态。 在启动任何批处理之前,将检查此约束。 此字段的值应介于 5 和 100 之间(含)。 如果 maxBatchInstancePercent 和 maxUnhealthyInstancePercent 都赋值,则 maxBatchInstancePercent 的值不应大于 maxUnhealthyInstancePercent。
|
maxUnhealthyUpgradedInstancePercent
|
integer
|
可发现处于不正常状态的已升级虚拟机实例的最大百分比。 升级每个批处理后,将进行此检查。 如果超过此百分比,滚动更新将中止。 此字段的值应介于 0 和 100 之间(含)。
|
pauseTimeBetweenBatches
|
string
|
完成一批中所有虚拟机的更新和开始下一批之间的等待时间。 持续时间应采用 ISO 8601 格式指定。
|
prioritizeUnhealthyInstances
|
boolean
|
在任何正常运行的实例之前,升级规模集中的所有不正常实例。
|
rollbackFailedInstancesOnPolicyBreach
|
boolean
|
如果违反滚动升级策略,回滚失败实例到以前的模型。
|
ScaleSettings
池的缩放设置
SecurityEncryptionTypes
指定托管磁盘的 EncryptionType。 它设置为 VMGuestStateOnly 以仅加密 VMGuestState blob,而 NonPersistedTPM 用于不保留 VMGuestState blob 中的固件状态。
注意:只能为机密 VM 设置它,在使用机密 VM 时是必需的。
名称 |
类型 |
说明 |
NonPersistedTPM
|
string
|
|
VMGuestStateOnly
|
string
|
|
SecurityProfile
指定虚拟机或虚拟机规模集的安全配置文件设置。
名称 |
类型 |
说明 |
encryptionAtHost
|
boolean
|
用户可以在请求中使用此属性来启用或禁用虚拟机或虚拟机规模集的主机加密。 这将为所有磁盘启用加密,包括主机本身的资源/临时磁盘。
|
securityType
|
SecurityTypes
|
指定虚拟机的 SecurityType。 必须将其设置为任何指定值才能启用 UefiSettings。
|
uefiSettings
|
UefiSettings
|
指定在创建虚拟机时使用的安全启动和 vTPM 等安全设置。
指定在创建虚拟机时使用的安全启动和 vTPM 等安全设置。
|
SecurityTypes
指定虚拟机的 SecurityType。 必须将其设置为任何指定值才能启用 UefiSettings。
名称 |
类型 |
说明 |
confidentialVM
|
string
|
Azure 机密计算为具有高安全性和机密性要求的租户提供机密 VM。 这些 VM 提供强大的硬件强制边界,以帮助满足安全需求。 可以使用机密 VM 进行迁移,而无需更改代码,而平台可保护 VM 的状态不被读取或修改。
|
trustedLaunch
|
string
|
受信任的启动可防范高级和持久性攻击技术。
|
ServiceArtifactReference
指定使用“latest”映像版本时,用于为规模集中的所有虚拟机设置相同映像版本的服务项目引用 ID。
名称 |
类型 |
说明 |
id
|
string
|
ServiceArtifactReference 的服务项目引用 ID
以 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/gallerys/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName} 的形式的服务项目引用 ID
|
StartTask
当计算节点加入 Azure Batch 服务中的池时或计算节点重新启动或重新映像时运行的任务。
名称 |
类型 |
默认值 |
说明 |
commandLine
|
string
|
|
启动任务的命令行。
命令行未在 shell 下运行,因此不能利用 shell 功能(如环境变量扩展)。 如果要利用这些功能,则应在命令行中调用 shell,例如在 Windows 中使用“cmd /c MyCommand”或在 Linux 中使用“/bin/sh -c MyCommand”。 如果指定了 startTask 的任何其他属性,则为必需。
|
containerSettings
|
TaskContainerSettings
|
|
启动任务所依据的容器的设置。
指定此项后,AZ_BATCH_NODE_ROOT_DIR(节点上的 Azure Batch 目录的根目录)以递归方式映射到容器中,所有任务环境变量都映射到容器中,任务命令行在容器中执行。
|
environmentSettings
|
EnvironmentSetting[]
|
|
启动任务的环境变量设置列表。
|
maxTaskRetryCount
|
integer
|
0
|
可以重试任务的最大次数。
如果 Batch 服务退出代码为非零,则重试任务。 请注意,此值专门控制重试次数。 Batch 服务将尝试一次任务,然后最多可以重试此限制。 例如,如果最大重试计数为 3,Batch 将尝试任务最多 4 次(一次初始尝试和 3 次重试)。 如果最大重试计数为 0,Batch 服务不会重试该任务。 如果最大重试计数为 -1,Batch 服务将重试任务,且没有限制。 默认值为 0
|
resourceFiles
|
ResourceFile[]
|
|
Batch 服务在运行命令行之前将下载到计算节点的文件列表。
|
userIdentity
|
UserIdentity
|
|
运行启动任务的用户标识。
如果省略,任务将作为任务唯一的非管理用户运行。
|
waitForSuccess
|
boolean
|
|
在计划计算节点上的任何任务之前,Batch 服务是否应等待启动任务成功完成(即退出代码 0)。
如果 true 并且启动任务在计算节点上失败,Batch 服务将启动任务重试到其最大重试计数(maxTaskRetryCount)。 如果任务在所有重试后仍未成功完成,Batch 服务会将计算节点标记为不可用,并且不会为其计划任务。 可以通过节点状态和计划错误详细信息来检测此条件。 如果为 false,Batch 服务不会等待启动任务完成。 在这种情况下,当启动任务仍在运行时,其他任务可以开始在计算节点上执行;即使启动任务失败,新任务也会继续在节点上计划。 默认值为 true。
|
StorageAccountType
用于创建数据磁盘或 OS 磁盘的存储帐户类型。
名称 |
类型 |
说明 |
Premium_LRS
|
string
|
数据磁盘/OS 磁盘应使用高级本地冗余存储。
|
StandardSSD_LRS
|
string
|
数据磁盘/OS 磁盘应使用标准 SSD 本地冗余存储。
|
Standard_LRS
|
string
|
数据磁盘/OS 磁盘应使用标准本地冗余存储。
|
TaskContainerSettings
任务的容器设置。
名称 |
类型 |
说明 |
containerHostBatchBindMounts
|
ContainerHostBatchBindMountEntry[]
|
要装载到容器任务的路径。
如果此数组为 null 或不存在,容器任务将在 Windows 中装载整个临时磁盘驱动器(或 Linux 中的AZ_BATCH_NODE_ROOT_DIR)。 如果此数组设置为空,则不会将任何数据路径装载到容器中。
|
containerRunOptions
|
string
|
容器创建命令的其他选项。
除了 Batch 服务控制的选项外,这些附加选项还作为“docker create”命令的参数提供。
|
imageName
|
string
|
用于创建要在其中运行任务的容器的映像。
这是完整的映像引用,如指定为“docker pull”。 如果未将标记作为映像名称的一部分提供,则标记“:latest”用作默认值。
|
registry
|
ContainerRegistry
|
包含容器映像的专用注册表。
如果在创建池时已提供此设置,则可以省略此设置。
|
workingDirectory
|
ContainerWorkingDirectory
|
用于指示容器任务工作目录所在的位置的标志。 默认值为“taskWorkingDirectory”。
|
TaskSchedulingPolicy
指定应如何跨计算节点分配任务。
UefiSettings
指定在创建虚拟机时使用的安全启动和 vTPM 等安全设置。
名称 |
类型 |
说明 |
secureBootEnabled
|
boolean
|
指定是否应在虚拟机上启用安全启动。
|
vTpmEnabled
|
boolean
|
指定是否应在虚拟机上启用 vTPM。
|
UpgradeMode
指定升级到规模集中虚拟机的模式。
可能的值包括:
手动 - 控制对规模集中虚拟机的更新的应用程序。 使用 manualUpgrade 操作执行此操作。
自动 - 规模集中的所有虚拟机同时自动更新。
滚动 - 规模集按批执行更新,并在两者之间有可选的暂停时间。
名称 |
类型 |
说明 |
automatic
|
string
|
规模集中的所有虚拟机都会同时自动更新。
|
manual
|
string
|
可以控制对规模集中虚拟机的更新的应用程序。 使用 manualUpgrade 操作执行此操作。
|
rolling
|
string
|
规模集中的现有实例将分批关闭以升级。 升级后的批处理完成后,实例将再次开始获取流量,下一批将开始。 这一直持续到所有实例 up-to-date。
|
UpgradePolicy
描述升级策略 - 自动、手动或滚动。
名称 |
类型 |
说明 |
automaticOSUpgradePolicy
|
AutomaticOSUpgradePolicy
|
用于执行自动 OS 升级的配置参数。
用于执行自动 OS 升级的配置参数。
|
mode
|
UpgradeMode
|
指定升级到规模集中虚拟机的模式。
可能的值包括:
手动 - 控制对规模集中虚拟机的更新的应用程序。 使用 manualUpgrade 操作执行此操作。
自动 - 规模集中的所有虚拟机同时自动更新。
滚动 - 规模集按批执行更新,并在两者之间有可选的暂停时间。
|
rollingUpgradePolicy
|
RollingUpgradePolicy
|
执行滚动升级时使用的配置参数。
执行滚动升级时使用的配置参数。
|
UserAccount
用于在 Azure Batch 节点上创建用户的属性。
名称 |
类型 |
说明 |
elevationLevel
|
ElevationLevel
|
用户帐户的提升级别。
nonAdmin - 自动用户是没有提升访问权限的标准用户。 管理员 - 自动用户是具有提升访问权限并具有完全管理员权限的用户。 默认值为 nonAdmin。
|
linuxUserConfiguration
|
LinuxUserConfiguration
|
用户帐户的特定于 Linux 的用户配置。
如果在 Windows 池上指定此属性,则忽略此属性。 如果未指定,则使用默认选项创建用户。
|
name
|
string
|
用户帐户的名称。 名称可以包含最大长度为 20 的任何 Unicode 字符。
|
password
|
string
|
用户帐户的密码。
|
windowsUserConfiguration
|
WindowsUserConfiguration
|
用户帐户的特定于 Windows 的用户配置。
只有在用户位于 Windows 池中时,才能指定此属性。 如果未指定且在 Windows 池上,则会使用默认选项创建用户。
|
UserAssignedIdentities
关联的用户标识列表。
名称 |
类型 |
说明 |
clientId
|
string
|
用户分配标识的客户端 ID。
|
principalId
|
string
|
用户分配标识的主体 ID。
|
UserIdentity
运行任务的用户标识的定义。
名称 |
类型 |
说明 |
autoUser
|
AutoUserSpecification
|
运行任务的自动用户。
userName 和 autoUser 属性互斥;必须指定一个,但不能同时指定两者。
|
userName
|
string
|
运行任务的用户标识的名称。
userName 和 autoUser 属性互斥;必须指定一个,但不能同时指定两者。
|
VirtualMachineConfiguration
基于 Azure 虚拟机基础结构的池中计算节点的配置。
名称 |
类型 |
说明 |
containerConfiguration
|
ContainerConfiguration
|
池的容器配置。
如果指定,则会在池中的每个节点上执行安装程序,以允许任务在容器中运行。 在此池上运行的所有常规任务和作业管理器任务都必须指定 containerSettings 属性,所有其他任务都可以指定它。
|
dataDisks
|
DataDisk[]
|
附加到池中计算节点的数据磁盘的配置。
如果池中的计算节点需要附加空数据磁盘,则必须指定此属性。
|
diskEncryptionConfiguration
|
DiskEncryptionConfiguration
|
池的磁盘加密配置。
如果指定了加密,则会在节点预配期间对池中的每个节点执行加密。
|
extensions
|
VMExtension[]
|
池的虚拟机扩展。
如果指定,此配置中提到的扩展将安装在每个节点上。
|
imageReference
|
ImageReference
|
对 Azure 虚拟机市场映像或要使用的自定义虚拟机映像的引用。
|
licenseType
|
string
|
部署操作系统时要使用的本地许可证的类型。
这仅适用于包含 Windows 操作系统的映像,并且仅在为将要部署的节点保留有效的本地许可证时使用。 如果省略,则不会应用本地许可折扣。 值为:
Windows_Server - 本地许可证适用于 Windows Server。
Windows_Client - 本地许可证适用于 Windows 客户端。
|
nodeAgentSkuId
|
string
|
要在池中的计算节点上预配的 Batch 节点代理的 SKU。
Batch 节点代理是在池中的每个节点上运行的程序,并在节点与 Batch 服务之间提供命令和控制接口。 对于不同的操作系统,节点代理(称为 SKU)有不同的实现。 必须指定与所选映像引用匹配的节点代理 SKU。 若要获取支持的节点代理 SKU 及其已验证映像引用列表,请参阅“列出支持的节点代理 SKU”操作。
|
nodePlacementConfiguration
|
NodePlacementConfiguration
|
池的节点放置配置。
此配置将指定池中节点的物理分配方式的规则。
|
osDisk
|
OSDisk
|
虚拟机操作系统磁盘的设置。
包含临时 OSDisk 设置的配置。
|
securityProfile
|
SecurityProfile
|
指定虚拟机或虚拟机规模集的安全配置文件设置。
指定虚拟机或虚拟机规模集的安全配置文件设置。
|
serviceArtifactReference
|
ServiceArtifactReference
|
指定使用“latest”映像版本时,用于为规模集中的所有虚拟机设置相同映像版本的服务项目引用 ID。
以 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/gallerys/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName} 的形式的服务项目引用 ID
|
windowsConfiguration
|
WindowsConfiguration
|
虚拟机上的 Windows 操作系统设置。
如果 imageReference 指定 Linux OS 映像,则不能指定此属性。
|
VMDiskSecurityProfile
指定托管磁盘的安全配置文件设置。
注意:只能为机密 VM 设置它,在使用机密 VM 时是必需的。
名称 |
类型 |
说明 |
securityEncryptionType
|
SecurityEncryptionTypes
|
指定托管磁盘的 EncryptionType。 它设置为 VMGuestStateOnly 以仅加密 VMGuestState blob,而 NonPersistedTPM 用于不保留 VMGuestState blob 中的固件状态。
注意:只能为机密 VM 设置它,在使用机密 VM 时是必需的。
|
VMExtension
虚拟机扩展的配置。
名称 |
类型 |
说明 |
autoUpgradeMinorVersion
|
boolean
|
指示扩展是否应在部署时使用较新的次要版本。 但是,部署后,除非重新部署,否则扩展不会升级次要版本,即使此属性设置为 true 也是如此。
|
enableAutomaticUpgrade
|
boolean
|
指示如果有较新版本的扩展可用,平台是否应自动升级扩展。
|
name
|
string
|
虚拟机扩展的名称。
|
protectedSettings
|
object
|
该扩展可以包含 protectedSettings 或 protectedSettingsFromKeyVault,或者根本不包含受保护的设置。
|
provisionAfterExtensions
|
string[]
|
扩展名称的集合。
需要预配此扩展的扩展名称的集合。
|
publisher
|
string
|
扩展处理程序发布者的名称。
|
settings
|
object
|
扩展的 JSON 格式公共设置。
|
type
|
string
|
扩展的类型。
|
typeHandlerVersion
|
string
|
脚本处理程序的版本。
|
WindowsConfiguration
要应用于虚拟机的 Windows 操作系统设置。
名称 |
类型 |
说明 |
enableAutomaticUpdates
|
boolean
|
是否在虚拟机上启用自动更新。
如果省略,则默认值为 true。
|
WindowsUserConfiguration
用于在 Windows 节点上创建用户帐户的属性。
名称 |
类型 |
说明 |
loginMode
|
LoginMode
|
用户的登录模式
指定用户的登录模式。 默认值为 Interactive。
|