简体   繁体   English

池存在后更新Azure Batch自动缩放公式

[英]Updating Azure Batch autoscale formula once pool exists

I can create a pool with an autoscale formula fine. 我可以创建一个自动缩放公式很好的池。 The code for this is as follows. 的代码如下。

var pool = client.PoolOperations.CreatePool(poolName, vmsize, new CloudServiceConfiguration(osFamily, osVersion));
pool.TaskSchedulingPolicy = new TaskSchedulingPolicy(ComputeNodeFillType.Pack);
pool.AutoScaleFormula = autoscaleFormula;
pool.AutoScaleEnabled = true;
pool.AutoScaleEvaluationInterval = new TimeSpan(0, 0, 5, 0);
pool.Commit();

However if once the pool exists, I try and update the AutoScale formula, I get an error. 但是,如果池一旦存在,我尝试更新AutoScale公式,则会收到错误消息。 The error is 错误是

{"The property AutoScaleFormula cannot be modified while the object is in the Bound state."} {“当对象处于绑定状态时,不能修改属性AutoScaleFormula。”}

The code is 该代码是

var client = BatchClient.Open(GetCloudSharedKeyCredentials(primary));
var pool = client.PoolOperations.GetPool(poolName);      
pool.AutoScaleFormula = formula;
pool.AutoScaleEnabled = true;
pool.AutoScaleEvaluationInterval = new TimeSpan(0, 0, 5, 0);
pool.Commit();

This used to work before I updated to the latest version of the Azure Batch library. 在我更新到Azure批处理库的最新版本之前,这种方法一直有效。 Has anyone got any experience of Azure Batch and can advise why I'm getting this error? 有没有人有任何Azure Batch的经验,可以告诉我为什么会出现此错误?

You can use the PoolOperations.EnableAutoScale method directly. 您可以直接使用PoolOperations.EnableAutoScale方法。 For your example, you could use the following: 对于您的示例,可以使用以下代码:

var client = BatchClient.Open(GetCloudSharedKeyCredentials(primary));
client.Pooloperations.EnableAutoScale(poolName, formula, TimeSpan.FromMinutes(5));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM