0

When I commit my formula, Azure complains about calculation errors. I narrowed it down to having a number with decimal places. Here’s my formula:

pivot = (0.15*($CurrentDedicated/20)+0.84);
target = $CurrentDedicated*(($CPUPercent.GetSample(TimeInterval_Minute*5)/100)/pivot);

Naturally, it complains about not having a sample, so I put in $CPUPercent.GetSamplePercent(TimeInterval_Minute*0,TimeInterval_Minute*5) in a ternary expression, but it complains about “evaluation error”. I figure this is happening because I’m trying to provision a fractional number of dedicated machines.

So… How can I round up and down in such an expression?

UPD:

So I found my problem, $CPUPercent.GetSample should not be used as a number. Instead, max(), min(), or avg() should be used on it to produce a number. The corrected formula is as follows:

samplepercent = $CPUPercent.GetSamplePercent(TimeInterval_Minute*0,TimeInterval_Minute*5);
pivot = (0.15*($CurrentDedicated/20)+0.84);
$TargetDedicated = samplepercent < 0.7 ? 1 : $CurrentDedicated*((avg($CPUPercent.GetSample(TimeInterval_Minute*5))/100)/pivot);

Sadly, there is no way to round up or down. The autoscale expressions to not have functions for it and do not have the % operator defined (x = x - x%1 and x = x - x%1 + 1 to round down and up respectively). This is sad indeed and may require me to review the above equation to make sure it works as intended.

Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67
Nomenator
  • 1,021
  • 1
  • 13
  • 28

1 Answers1

1

Check this thread, they have some examples https://social.msdn.microsoft.com/Forums/azure/en-US/21161846-6b6b-4e34-85fc-333663414714/autoscaleformula-improvements-needed?forum=azurebatch

Canoas
  • 1,981
  • 1
  • 13
  • 13
  • Thanks. Reading this very carefully, I found that my use of CPUPercent.GetSample is incorrect, when I am treating it as a number, but it is, in fact, a vector, so that is the problem, not fractional values. – Nomenator Jan 20 '16 at 03:15