public async Task UpdatePoolVmImage()
{
// Authenticate
var clientId = Environment.GetEnvironmentVariable("CLIENT_ID");
var clientSecret = Environment.GetEnvironmentVariable("CLIENT_SECRET");
var tenantId = Environment.GetEnvironmentVariable("TENANT_ID");
var subscriptionId = Environment.GetEnvironmentVariable("SUBSCRIPTION_ID");
ClientSecretCredential credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
ArmClient client = new ArmClient(credential, subscriptionId);
// Get an existing Batch account
string resourceGroupName = "<resourcegroup>";
string accountName = "<batchaccount>";
ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
// get the collection of this BatchAccountPoolResource
BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools();
// Update the pool
string poolName = "mypool";
BatchAccountPoolData data = new BatchAccountPoolData()
{
DeploymentConfiguration = new BatchDeploymentConfiguration()
{
VmConfiguration = new BatchVmConfiguration(new BatchImageReference()
{
Publisher = "MicrosoftWindowsServer",
Offer = "WindowsServer",
Sku = "2022-datacenter-azure-edition-smalldisk",
Version = "latest",
},
nodeAgentSkuId: "batch.node.windows amd64"),
},
};
ArmOperation<BatchAccountPoolResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data);
BatchAccountPoolResource result = lro.Value;
BatchAccountPoolData resourceData = result.Data;
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}