BatchClient.CreatePoolAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreatePoolAsync(BatchPoolCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) |
Creates a Pool to the specified Account. |
CreatePoolAsync(RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext) |
[Protocol Method] Creates a Pool to the specified Account.
|
CreatePoolAsync(BatchPoolCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken)
- Source:
- BatchClientCustom.cs
Creates a Pool to the specified Account.
public virtual System.Threading.Tasks.Task<Azure.Response> CreatePoolAsync(Azure.Compute.Batch.BatchPoolCreateContent pool, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreatePoolAsync : Azure.Compute.Batch.BatchPoolCreateContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.CreatePoolAsync : Azure.Compute.Batch.BatchPoolCreateContent * Nullable<int> * Nullable<DateTimeOffset> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreatePoolAsync (pool As BatchPoolCreateContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)
Parameters
The Pool to be created.
The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. If the value is larger than 30, the default will be used instead.".
- ocpdate
- Nullable<DateTimeOffset>
The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
pool
is null.
Examples
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("mypool01", "Standard_D1_v2")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64"),
TargetDedicatedNodes = 2,
NetworkConfiguration = new NetworkConfiguration
{
EnableAcceleratedNetworking = true,
},
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("pool2", "standard_a1")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "20_04-lts",
}, "batch.node.ubuntu 20.04"),
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 5,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
TaskSlotsPerNode = 3,
TaskSchedulingPolicy = new BatchTaskSchedulingPolicy(BatchNodeFillType.Spread),
MountConfiguration = {new MountConfiguration
{
AzureBlobFileSystemConfiguration = new AzureBlobFileSystemConfiguration("accountName", "blobContainerName", "bfusepath")
{
AccountKey = "accountKey",
},
}, new MountConfiguration
{
AzureFileShareConfiguration = new AzureFileShareConfiguration("accountName", "https://myaccount.file.core.windows.net/fileshare", "accountKey", "filesharepath")
{
MountOptions = "mount options ver=1.0",
},
}, new MountConfiguration
{
NfsMountConfiguration = new NfsMountConfiguration("somesource nfs url", "mountpath")
{
MountOptions = "mount options ver=1.0",
},
}, new MountConfiguration
{
CifsMountConfiguration = new CifsMountConfiguration("accountName", "//myaccount.file.core.windows.net/file", "mountpath", "password")
{
MountOptions = "mount options ver=1.0",
},
}},
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("mypool001", "standard_d2s_v3")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-focal",
Sku = "20_04-lts",
}, "batch.node.ubuntu 20.04")
{
OsDisk = new OSDisk
{
EphemeralOSDiskSettings = new DiffDiskSettings
{
Placement = DiffDiskPlacement.CacheDisk,
},
Caching = CachingType.ReadWrite,
DiskSizeGB = 100,
ManagedDisk = new ManagedDisk
{
StorageAccountType = StorageAccountType.StandardSSDLRS,
},
},
},
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 1,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
TaskSlotsPerNode = 1,
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("mypool001", "STANDARD_DC2s_V2")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18_04-lts-gen2",
Version = "latest",
}, "batch.node.ubuntu 18.04"),
ResourceTags =
{
["TagName1"] = "TagValue1",
["TagName2"] = "TagValue2"
},
TargetDedicatedNodes = 1,
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("mypool001", "STANDARD_DC2s_V2")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "UbuntuServer",
Sku = "18_04-lts-gen2",
Version = "latest",
}, "batch.node.ubuntu 18.04")
{
SecurityProfile = new SecurityProfile(true, SecurityTypes.TrustedLaunch, new UefiSettings
{
SecureBootEnabled = false,
}),
},
TargetDedicatedNodes = 1,
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("pool2", "standard_a1")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-focal",
Sku = "20_04-lts",
}, "batch.node.ubuntu 20.04"),
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 5,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
EnableInterNodeCommunication = true,
TaskSlotsPerNode = 3,
TaskSchedulingPolicy = new BatchTaskSchedulingPolicy(BatchNodeFillType.Spread),
Metadata = { new MetadataItem("myproperty", "myvalue") },
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("pool2", "standard_a1")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-focal",
Sku = "120_04-lts",
}, "batch.node.ubuntu 20.04")
{
ContainerConfiguration = new ContainerConfiguration(ContainerType.DockerCompatible)
{
ContainerImageNames = { "busybox" },
},
},
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 5,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
TaskSlotsPerNode = 3,
TaskSchedulingPolicy = new BatchTaskSchedulingPolicy(BatchNodeFillType.Spread),
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("pool2", "standard_a1")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-focal",
Sku = "20_04-lts",
}, "batch.node.ubuntu 20.04")
{
Extensions = {new VMExtension("batchextension1", "Microsoft.Azure.KeyVault", "KeyVaultForLinux")
{
TypeHandlerVersion = "2.0",
AutoUpgradeMinorVersion = true,
EnableAutomaticUpgrade = true,
Settings =
{
["secretsManagementSettingsKey"] = "secretsManagementSettingsValue",
["authenticationSettingsKey"] = "authenticationSettingsValue"
},
}},
},
ResizeTimeout = XmlConvert.ToTimeSpan("PT15M"),
TargetDedicatedNodes = 5,
TargetLowPriorityNodes = 0,
EnableAutoScale = false,
EnableInterNodeCommunication = true,
TaskSlotsPerNode = 3,
TaskSchedulingPolicy = new BatchTaskSchedulingPolicy(BatchNodeFillType.Spread),
Metadata = { new MetadataItem("myproperty", "myvalue") },
TargetNodeCommunicationMode = BatchNodeCommunicationMode.Simplified,
};
Response response = await client.CreatePoolAsync(pool);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
BatchPoolCreateContent pool = new BatchPoolCreateContent("mypool002", "Standard_A1_v2")
{
VirtualMachineConfiguration = new VirtualMachineConfiguration(new ImageReference
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2016-datacenter-smalldisk",
Version = "latest",
}, "batch.node.windows amd64")
{
WindowsConfiguration = new WindowsConfiguration
{
EnableAutomaticUpdates = false,
},
ServiceArtifactReference = new ServiceArtifactReference("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"),
},
TargetDedicatedNodes = 2,
};
Response response = await client.CreatePoolAsync(pool);
Remarks
When naming Pools, avoid including sensitive information such as user names or secret project names. This information may appear in telemetry logs accessible to Microsoft Support engineers.
Applies to
CreatePoolAsync(RequestContent, Nullable<Int32>, Nullable<DateTimeOffset>, RequestContext)
- Source:
- BatchClientCustom.cs
[Protocol Method] Creates a Pool to the specified Account.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreatePoolAsync(BatchPoolCreateContent, Nullable<Int32>, Nullable<DateTimeOffset>, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreatePoolAsync(Azure.Core.RequestContent content, int? timeOutInSeconds = default, DateTimeOffset? ocpdate = default, Azure.RequestContext context = default);
abstract member CreatePoolAsync : Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreatePoolAsync : Azure.Core.RequestContent * Nullable<int> * Nullable<DateTimeOffset> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreatePoolAsync (content As RequestContent, Optional timeOutInSeconds As Nullable(Of Integer) = Nothing, Optional ocpdate As Nullable(Of DateTimeOffset) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
The maximum time that the server can spend processing the request, in seconds. The default is 30 seconds. If the value is larger than 30, the default will be used instead.".
- ocpdate
- Nullable<DateTimeOffset>
The time the request was issued. Client libraries typically set this to the current system clock time; set it explicitly if you are calling the REST API directly.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "mypool01",
vmSize = "Standard_D1_v2",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "MicrosoftWindowsServer",
offer = "WindowsServer",
sku = "2016-datacenter-smalldisk",
version = "latest",
},
nodeAgentSKUId = "batch.node.windows amd64",
},
targetDedicatedNodes = 2,
networkConfiguration = new
{
enableAcceleratedNetworking = true,
},
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "pool2",
vmSize = "standard_a1",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "UbuntuServer",
sku = "20_04-lts",
},
nodeAgentSKUId = "batch.node.ubuntu 20.04",
},
mountConfiguration = new object[]
{
new
{
azureBlobFileSystemConfiguration = new
{
accountName = "accountName",
containerName = "blobContainerName",
accountKey = "accountKey",
relativeMountPath = "bfusepath",
},
},
new
{
azureFileShareConfiguration = new
{
accountName = "accountName",
azureFileUrl = "https://myaccount.file.core.windows.net/fileshare",
accountKey = "accountKey",
relativeMountPath = "filesharepath",
mountOptions = "mount options ver=1.0",
},
},
new
{
nfsMountConfiguration = new
{
source = "somesource nfs url",
relativeMountPath = "mountpath",
mountOptions = "mount options ver=1.0",
},
},
new
{
cifsMountConfiguration = new
{
username = "accountName",
password = "password",
source = "//myaccount.file.core.windows.net/file",
relativeMountPath = "mountpath",
mountOptions = "mount options ver=1.0",
},
}
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 5,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 3,
taskSchedulingPolicy = new
{
nodeFillType = "spread",
},
enableAutoScale = false,
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "mypool001",
vmSize = "standard_d2s_v3",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "0001-com-ubuntu-server-focal",
sku = "20_04-lts",
},
osDisk = new
{
diskSizeGB = 100,
managedDisk = new
{
storageAccountType = "standardssd_lrs",
},
caching = "readwrite",
ephemeralOSDiskSettings = new
{
placement = "cachedisk",
},
},
nodeAgentSKUId = "batch.node.ubuntu 20.04",
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 1,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 1,
enableAutoScale = false,
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "mypool001",
vmSize = "STANDARD_DC2s_V2",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "UbuntuServer",
sku = "18_04-lts-gen2",
version = "latest",
},
nodeAgentSKUId = "batch.node.ubuntu 18.04",
},
targetDedicatedNodes = 1,
resourceTags = new
{
TagName1 = "TagValue1",
TagName2 = "TagValue2",
},
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "mypool001",
vmSize = "STANDARD_DC2s_V2",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "UbuntuServer",
sku = "18_04-lts-gen2",
version = "latest",
},
nodeAgentSKUId = "batch.node.ubuntu 18.04",
securityProfile = new
{
securityType = "trustedLaunch",
encryptionAtHost = true,
uefiSettings = new
{
secureBootEnabled = false,
},
},
},
targetDedicatedNodes = 1,
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "pool2",
vmSize = "standard_a1",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "0001-com-ubuntu-server-focal",
sku = "20_04-lts",
},
nodeAgentSKUId = "batch.node.ubuntu 20.04",
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 5,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 3,
taskSchedulingPolicy = new
{
nodeFillType = "spread",
},
enableAutoScale = false,
enableInterNodeCommunication = true,
metadata = new object[]
{
new
{
name = "myproperty",
value = "myvalue",
}
},
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "pool2",
vmSize = "standard_a1",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "0001-com-ubuntu-server-focal",
sku = "120_04-lts",
},
nodeAgentSKUId = "batch.node.ubuntu 20.04",
containerConfiguration = new
{
type = "dockerCompatible",
containerImageNames = new object[]
{
"busybox"
},
},
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 5,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 3,
taskSchedulingPolicy = new
{
nodeFillType = "spread",
},
enableAutoScale = false,
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "pool2",
vmSize = "standard_a1",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "Canonical",
offer = "0001-com-ubuntu-server-focal",
sku = "20_04-lts",
},
nodeAgentSKUId = "batch.node.ubuntu 20.04",
extensions = new object[]
{
new
{
name = "batchextension1",
type = "KeyVaultForLinux",
publisher = "Microsoft.Azure.KeyVault",
typeHandlerVersion = "2.0",
autoUpgradeMinorVersion = true,
enableAutomaticUpgrade = true,
settings = new
{
secretsManagementSettingsKey = "secretsManagementSettingsValue",
authenticationSettingsKey = "authenticationSettingsValue",
},
}
},
},
resizeTimeout = "PT15M",
targetDedicatedNodes = 5,
targetLowPriorityNodes = 0,
taskSlotsPerNode = 3,
taskSchedulingPolicy = new
{
nodeFillType = "spread",
},
enableAutoScale = false,
enableInterNodeCommunication = true,
metadata = new object[]
{
new
{
name = "myproperty",
value = "myvalue",
}
},
targetNodeCommunicationMode = "simplified",
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
This sample shows how to call CreatePoolAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
BatchClient client = new BatchClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
id = "mypool002",
vmSize = "Standard_A1_v2",
virtualMachineConfiguration = new
{
imageReference = new
{
publisher = "MicrosoftWindowsServer",
offer = "WindowsServer",
sku = "2016-datacenter-smalldisk",
version = "latest",
},
windowsConfiguration = new
{
enableAutomaticUpdates = false,
},
serviceArtifactReference = new
{
id = "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile",
},
nodeAgentSKUId = "batch.node.windows amd64",
},
targetDedicatedNodes = 2,
});
Response response = await client.CreatePoolAsync(content);
Console.WriteLine(response.Status);
Applies to
Azure SDK for .NET