Skip to content

Commit 17fa81b

Browse files
authored
Merge pull request #318 from arocho032/master
Updated Pool creation to use VirtualMachineConfiguration
2 parents 079a7d2 + 00dd6e0 commit 17fa81b

File tree

27 files changed

+222
-45
lines changed

27 files changed

+222
-45
lines changed

CSharp/ArticleProjects/ApplicationInsights/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,16 @@ binaries on the machine and keep a process running indefinitely.
310310
CloudPool pool = client.PoolOperations.CreatePool(
311311
topNWordsConfiguration.PoolId,
312312
targetDedicated: topNWordsConfiguration.PoolNodeCount,
313-
virtualMachineSize: "standard_d1_v2",
314-
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5"));
315-
313+
virtualMachineSize: "standard_d2_v3",
314+
virtualMachineConfiguration: new VirtualMachineConfiguration(
315+
imageReference: new ImageReference(
316+
publisher: topNWordsConfiguration.ImagePublisher,
317+
offer: topNWordsConfiguration.ImageOffer,
318+
sku: topNWordsConfiguration.ImageSku,
319+
version: topNWordsConfiguration.ImageVersion
320+
),
321+
nodeAgentSkuId: topNWordsConfiguration.NodeAgentSkuId));
322+
316323
// Create file staging objects that represent the executable and its dependent assembly to run as the task.
317324
// These files are copied to every node before the corresponding task is scheduled to run on that node.
318325
FileToStage applicationMonitoringExe = new FileToStage(BatchApplicationInsightsAssemblyExeName, stagingStorageAccount);

CSharp/ArticleProjects/ApplicationInsights/TopNWords/Job.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@ public async static Task JobMain(string[] args)
8383
CloudPool pool = client.PoolOperations.CreatePool(
8484
topNWordsConfiguration.PoolId,
8585
targetDedicatedComputeNodes: topNWordsConfiguration.PoolNodeCount,
86-
virtualMachineSize: "standard_d1_v2",
87-
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5"));
86+
virtualMachineSize: topNWordsConfiguration.PoolNodeVirtualMachineSize,
87+
virtualMachineConfiguration: new VirtualMachineConfiguration(
88+
imageReference: new ImageReference(
89+
publisher: topNWordsConfiguration.ImagePublisher,
90+
offer: topNWordsConfiguration.ImageOffer,
91+
sku: topNWordsConfiguration.ImageSku,
92+
version: topNWordsConfiguration.ImageVersion
93+
),
94+
nodeAgentSkuId: topNWordsConfiguration.NodeAgentSkuId));
8895

8996
List<string> files = new List<string>
9097
{

CSharp/ArticleProjects/ApplicationInsights/TopNWords/Settings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ public class Settings
1616
public bool ShouldDeleteJob { get; set; }
1717
public bool ShouldDeletePool { get; set; }
1818
public bool ShouldDeleteContainer { get; set; }
19+
public string PoolNodeVirtualMachineSize { get; set; }
20+
public string ImagePublisher { get; set; }
21+
public string ImageOffer { get; set; }
22+
public string ImageSku { get; set; }
23+
public string ImageVersion { get; set; }
24+
public string NodeAgentSkuId { get; set; }
1925
}
2026
}

CSharp/ArticleProjects/ApplicationInsights/TopNWords/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
"shouldDeletePool": false,
77
"shouldDeleteContainer": true,
88
"poolId": "TopNWordsPool",
9-
"jobId": "TopNWordsJob"
9+
"jobId": "TopNWordsJob",
10+
"poolNodeVirtualMachineSize": "standard_d2_v3",
11+
"imagePublisher": "MicrosoftWindowsServer",
12+
"imageOffer": "WindowsServer",
13+
"imageSku": "2016-Datacenter-smalldisk",
14+
"imageVersion": "latest",
15+
"nodeAgentSkuId": "batch.node.windows amd64"
1016
}

CSharp/ArticleProjects/JobPrepRelease/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private static async Task MainAsync(string[] args)
7474
CloudPool pool = await ArticleHelpers.CreatePoolIfNotExistAsync(
7575
batchClient,
7676
poolId,
77-
"standard_d1_v2",
77+
"standard_d2_v3",
7878
2,
7979
1);
8080

CSharp/ArticleProjects/MultiInstanceTasks/Program.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,17 @@ private static async Task CreatePoolAsync(BatchClient batchClient, string poolId
198198
CloudPool unboundPool =
199199
batchClient.PoolOperations.CreatePool(
200200
poolId: poolId,
201-
virtualMachineSize: "standard_d1_v2",
201+
virtualMachineSize: "standard_d2_v3",
202202
targetDedicatedComputeNodes: numberOfNodes,
203-
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5"));
204-
203+
virtualMachineConfiguration: new VirtualMachineConfiguration(
204+
imageReference: new ImageReference(
205+
publisher: "MicrosoftWindowsServer",
206+
offer: "WindowsServer",
207+
sku: "2016-Datacenter-smalldisk",
208+
version: "latest"
209+
),
210+
nodeAgentSkuId: "batch.node.windows amd64"));
211+
205212
// REQUIRED for communication between the MS-MPI processes (in this
206213
// sample, MPIHelloWorld.exe) running on the different nodes
207214
unboundPool.InterComputeNodeCommunicationEnabled = true;

CSharp/ArticleProjects/ParallelTasks/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void Main(string[] args)
4545
private static async Task MainAsync(string[] args)
4646
{
4747
// You may adjust these values to experiment with different compute resource scenarios.
48-
const string nodeSize = "standard_d1_v2";
48+
const string nodeSize = "standard_d2_v3";
4949
const int nodeCount = 4;
5050
const int taskSlotsPerNode = 4;
5151
const int taskCount = 32;

CSharp/ArticleProjects/PersistOutputs/FileConventionsExample.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ public static async Task<CloudBlobContainer> Run(
2424
const string appPackageVersion = "1.0";
2525

2626
// Create and configure an unbound pool.
27-
CloudPool pool = batchClient.PoolOperations.CreatePool(
28-
poolId: poolId,
29-
virtualMachineSize: "standard_d1_v2",
27+
Func<ImageReference, bool> imageScanner = imageRef =>
28+
imageRef.Publisher.Equals("MicrosoftWindowsServer", StringComparison.InvariantCultureIgnoreCase) &&
29+
imageRef.Offer.Equals("WindowsServer", StringComparison.InvariantCultureIgnoreCase) &&
30+
imageRef.Sku.IndexOf("2012-R2-Datacenter", StringComparison.InvariantCultureIgnoreCase) > -1;
31+
32+
ImageInformation imageInfo = await SampleHelpers.GetNodeAgentSkuReferenceAsync(batchClient, imageScanner);
33+
34+
// Create and configure an unbound pool.
35+
CloudPool pool = batchClient.PoolOperations.CreatePool(poolId: poolId,
36+
virtualMachineSize: "standard_d2_v3",
3037
targetDedicatedComputeNodes: nodeCount,
31-
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5"));
38+
virtualMachineConfiguration: new VirtualMachineConfiguration(
39+
imageInfo.ImageReference,
40+
imageInfo.NodeAgentSkuId));
3241

3342
// Specify the application and version to deploy to the compute nodes. You must
3443
// first build PersistOutputsTask, then upload it as an application package.

CSharp/ArticleProjects/PersistOutputs/OutputFilesExample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private static async Task CreatePoolAsync(BatchClient batchClient, string poolId
191191

192192
// Create and configure an unbound pool.
193193
CloudPool pool = batchClient.PoolOperations.CreatePool(poolId: poolId,
194-
virtualMachineSize: "standard_d1_v2",
194+
virtualMachineSize: "standard_d2_v3",
195195
targetDedicatedComputeNodes: nodeCount,
196196
virtualMachineConfiguration: new VirtualMachineConfiguration(
197197
imageInfo.ImageReference,

CSharp/ArticleProjects/TaskDependencies/Program.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static void Main(string[] args)
3838
private static async Task MainAsync(string[] args)
3939
{
4040
// You may adjust these values to experiment with different compute resource scenarios.
41-
const string nodeSize = "standard_d1_v2";
41+
const string nodeSize = "standard_d2_v3";
4242
const string osFamily = "5";
4343
const int nodeCount = 1;
4444

@@ -66,8 +66,15 @@ private static async Task MainAsync(string[] args)
6666
CloudPool unboundPool =
6767
batchClient.PoolOperations.CreatePool(
6868
poolId: poolId,
69-
cloudServiceConfiguration: new CloudServiceConfiguration(osFamily),
70-
virtualMachineSize: nodeSize,
69+
virtualMachineSize: "standard_d2_v3",
70+
virtualMachineConfiguration: new VirtualMachineConfiguration(
71+
imageReference: new ImageReference(
72+
publisher: "MicrosoftWindowsServer",
73+
offer: "WindowsServer",
74+
sku: "2016-Datacenter-smalldisk",
75+
version: "latest"
76+
),
77+
nodeAgentSkuId: "batch.node.windows amd64"),
7178
targetDedicatedComputeNodes: nodeCount);
7279
await unboundPool.CommitAsync();
7380

0 commit comments

Comments
 (0)