Вы не можете использовать toscalar () со строковым контекстом, как описано здесь: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/functions/user-defined-functions#user -defined-functions-Use-Ограничения
Способ решения вашего сценария - это использовать перекрестное соединение и фильтр после объединения:
let start = ago(14d);
let end = now();
let timeGrain = 1h;
let Azure_P_Disk_Options =
datatable (SKU:string, Capacity_Limit:long, Price_per_month:decimal, IOPS_Limit:long, Throughput_Limit:long)
[
"P1", 4, 0.33, 120, 25,
"P2", 8, 0.66, 120, 25,
"P3", 16, 1.32, 120, 25,
"P4", 32, 5.28, 120, 25,
"P6", 64, 10.21, 240, 50,
"P10", 128, 19.71, 500, 100,
"P15", 256, 38.02, 1100, 125,
"P20", 512, 73.22, 2300, 150,
"P30", 1024, 135.17, 5000, 200,
"P40", 2048, 259.05, 7500, 250,
"P50", 4096, 495.57, 7500, 250,
"P60", 8192, 946.08, 16000, 500,
"P70", 16384, 1802.06, 18000, 750,
"P80", 32768, 3604.11, 20000, 900,
]
;
//
let Azure_E_Disk_Options =
datatable (SKU:string, Capacity_Limit:long, Price_per_month:decimal, IOPS_Limit:long, Throughput_Limit:long)
[
"E1", 4, 0.15, 120, 25,
"E2", 8, 0.30, 120, 25,
"E3", 16, 0.60, 120, 25,
"E4", 32, 2.40, 120, 25,
"E6", 64, 4.80, 240, 50,
"E10", 128, 9.60, 500, 60,
"E15", 256, 19.20, 500, 60,
"E20", 512, 38.40, 500, 60,
"E30", 1024, 76.80, 500, 60,
"E40", 2048, 153.60, 500, 60,
"E50", 4096, 307.20, 500, 60,
"E60", 8192, 614.40, 2000, 400,
"E70", 16384, 1228.80, 4000, 600,
"E80", 32768, 2457.60, 6000, 750,
]
;
//
let Azure_S_Disk_Options =
datatable (SKU:string, Capacity_Limit:long, Price_per_month:decimal, IOPS_Limit:long, Throughput_Limit:long)
[
"S4", 32, 1.54, 500, 60,
"S6", 64, 3.01, 500, 60,
"S10", 128, 5.89, 500, 60,
"S15", 256, 11.33, 500, 60,
"S20", 512, 21.76, 500, 60,
"S30", 1024, 40.96, 500, 60,
"S40", 2048, 77.83, 500, 60,
"S50", 4096, 143.36, 500, 60,
"S60", 8192, 262.14, 1300, 300,
"S70", 16384, 491.52, 2000, 500,
"S80", 32768, 953.55, 2000, 500
]
;
//
let Azure_Disk_Options_RAW =
Azure_P_Disk_Options
| serialize
| extend Capacity_Start = prev(Capacity_Limit)
| extend IOPS_Start = prev(IOPS_Limit)
| extend Throughput_Start = prev(Throughput_Limit)
| union
(
Azure_E_Disk_Options
| serialize
| extend Capacity_Start = prev(Capacity_Limit)
| extend IOPS_Start = prev(IOPS_Limit)
| extend Throughput_Start = prev(Throughput_Limit)
)
| union
(
Azure_S_Disk_Options
| serialize
| extend Capacity_Start = prev(Capacity_Limit)
| extend IOPS_Start = prev(IOPS_Limit)
| extend Throughput_Start = prev(Throughput_Limit)
);
//
let Azure_Disk_Options =
Azure_Disk_Options_RAW
| serialize
| extend Price_per_month = round(Price_per_month, 2)
| extend Capacity_Start = iif(Capacity_Start > 0, Capacity_Start, 0)
| extend IOPS_Start = iif(IOPS_Start > 0, IOPS_Start, 0)
| extend Throughput_Start = iif(Throughput_Start > 0, Throughput_Start, 0)
| extend Rownumber = row_number()
| project-reorder Rownumber
;
//
let Disk_Summary =
datatable (Computer:string, Drive_Letter:string, IOPS:decimal, Throughput:decimal, GB_Used:decimal)
[
"dev", "C", 23.945, 0.407, 1024,
"dev", "F", 2.16, 0.014, 1024,
"test", "C", 9.77, 0.24, 1024,
"test", "F", 2.22, 0.017, 1024,
"prod", "C", 16.597, 0.377, 1024,
"prod", "F", 14.149, 0.068, 1024,
]
;
Disk_Summary
| summarize IOPS = any(IOPS) ,Throughput_in_MB = any(Throughput) ,GB_Used = any(GB_Used) by Computer, Drive_Letter
| extend _key = 1
| join kind=inner (Azure_Disk_Options_RAW | extend _key=1) on _key
| where GB_Used < Capacity_Limit and IOPS < IOPS_Limit and Throughput_in_MB < Throughput_Limit
| summarize arg_min(Price_per_month, *) by Computer, Drive_Letter
| project-away _key, _key1