C# 一旦池存在,更新Azure批处理自动缩放公式
我可以使用自动缩放公式创建池。代码如下所示C# 一旦池存在,更新Azure批处理自动缩放公式,c#,.net,azure,azure-batch,C#,.net,Azure,Azure Batch,我可以使用自动缩放公式创建池。代码如下所示 var pool = client.PoolOperations.CreatePool(poolName, vmsize, new CloudServiceConfiguration(osFamily, osVersion)); pool.TaskSchedulingPolicy = new TaskSchedulingPolicy(ComputeNodeFillType.Pack); pool.AutoScaleFormula = autoscale
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();
但是,如果一旦池存在,我尝试更新自动缩放公式,就会出现错误。错误是
{“当对象处于活动状态时,无法修改属性AutoScaleFormula
处于束缚态。”}
代码是
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();
在我更新到最新版本的Azure批处理库之前,这项功能就可以正常工作了。有没有人有过Azure批处理的经验,可以告诉我为什么会出现此错误?您可以直接使用PoolOperations.EnableAutoScale方法。 对于您的示例,您可以使用以下内容:
var client = BatchClient.Open(GetCloudSharedKeyCredentials(primary));
client.Pooloperations.EnableAutoScale(poolName, formula, TimeSpan.FromMinutes(5));