Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 一旦池存在,更新Azure批处理自动缩放公式_C#_.net_Azure_Azure Batch - Fatal编程技术网

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));