This page contains Windows bias

About This Page

This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.

Bias Analysis

Bias Types:
⚠️ windows_first
⚠️ powershell_heavy
⚠️ windows_tools
⚠️ missing_linux_example
Summary:
The documentation page exhibits a Windows bias in several ways: .NET (C#) and Windows-centric examples are consistently presented first and in greater detail, including code snippets that use Windows VM images (e.g., MicrosoftWindowsServer) and node agent SKUs for Windows. PowerShell and .NET SDKs are emphasized, with only a single Python example provided for Linux (Ubuntu) and no Bash/CLI or Linux shell examples. There are no explicit Linux command-line or scripting examples, and Windows terminology and tools are referenced more frequently and prominently than their Linux equivalents.
Recommendations:
  • Provide Linux-first or side-by-side examples for all SDKs, including Bash/CLI and Python, not just .NET/C#.
  • Include explicit Linux VM image references and node agent SKUs in .NET and other language examples, not just Windows.
  • Add examples using Azure CLI and Bash scripts for common operations (e.g., creating pools, enabling autoscale), to complement PowerShell and .NET code.
  • Ensure that Linux tools and workflows are mentioned with equal prominence and detail as Windows/PowerShell/.NET equivalents.
  • Review terminology and ordering to avoid always listing Windows/PowerShell/.NET first; alternate or parallelize with Linux/Python/CLI where possible.
GitHub Create pull request

Scan History

Date Scan ID Status Bias Status
2025-08-17 00:01 #83 in_progress ✅ Clean
2025-07-13 21:37 #48 completed ❌ Biased
2025-07-09 13:09 #3 cancelled ✅ Clean
2025-07-08 04:23 #2 cancelled ❌ Biased

Flagged Code Snippets

$CPUPercent.GetSample(TimeInterval_Minute * 5)
$TargetDedicatedNodes = min(400, $totalDedicatedNodes);
$myNewVariable = function($ServiceDefinedVariable, $myCustomVariable);
$variable1 = function1($ServiceDefinedVariable); $variable2 = function2($OtherServiceDefinedVariable, $variable1);
AutoScaleRun.Results: $TargetDedicatedNodes=10; $NodeDeallocationOption=requeue; $curTime=2016-10-13T19:18:47.805Z; $isWeekday=1; $isWorkingWeekdayHour=0; $workHours=0
$curTime = time(); $workHours = $curTime.hour >= 8 && $curTime.hour < 18; $isWeekday = $curTime.weekday >= 1 && $curTime.weekday <= 5; $isWorkingWeekdayHour = $workHours && $isWeekday; $TargetDedicatedNodes = $isWorkingWeekdayHour ? 20:10; $NodeDeallocationOption = taskcompletion;
string now = DateTime.UtcNow.ToString("r"); string formula = string.Format(@" $TargetDedicatedNodes = {1}; lifespan = time() - time(""{0}""); span = TimeInterval_Minute * 60; startup = TimeInterval_Minute * 10; ratio = 50; $TargetDedicatedNodes = (lifespan > startup ? (max($RunningTasks.GetSample(span, ratio), $ActiveTasks.GetSample(span, ratio)) == 0 ? 0 : $TargetDedicatedNodes) : {1}); ", now, 4);
startingNumberOfVMs = 1; maxNumberofVMs = 25; pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(TimeInterval_Minute * 15); pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(TimeInterval_Minute * 15)); $TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples); $NodeDeallocationOption = taskcompletion;
maxNumberofVMs = 25; $TargetDedicatedNodes = min(maxNumberofVMs, $PreemptedNodeCount.GetSample(180 * TimeInterval_Second)); $TargetLowPriorityNodes = min(maxNumberofVMs , maxNumberofVMs - $TargetDedicatedNodes); $NodeDeallocationOption = taskcompletion;
$runningTasksSample = $RunningTasks.GetSample(1 * TimeInterval_Minute, 6 * TimeInterval_Minute);
$runningTasksSample=[1,1,1,1,1,1,1,1,1,1];
$runningTasksSample = $RunningTasks.GetSample(60 * TimeInterval_Second, 120 * TimeInterval_Second, 75);
$totalDedicatedNodes = (min($CPUPercent.GetSample(TimeInterval_Minute * 10)) > 0.7) ? ($CurrentDedicatedNodes * 1.1) : $CurrentDedicatedNodes;
$totalDedicatedNodes = (avg($CPUPercent.GetSample(TimeInterval_Minute * 60)) < 0.2) ? ($CurrentDedicatedNodes * 0.9) : $totalDedicatedNodes;
$NodeDeallocationOption = taskcompletion;
$totalDedicatedNodes = (min($CPUPercent.GetSample(TimeInterval_Minute * 10)) > 0.7) ? ($CurrentDedicatedNodes * 1.1) : $CurrentDedicatedNodes; $totalDedicatedNodes = (avg($CPUPercent.GetSample(TimeInterval_Minute * 60)) < 0.2) ? ($CurrentDedicatedNodes * 0.9) : $totalDedicatedNodes; $TargetDedicatedNodes = min(400, $totalDedicatedNodes); $NodeDeallocationOption = taskcompletion;
CloudPool pool = myBatchClient.PoolOperations.CreatePool( poolId: "mypool", virtualMachineSize: "standard_d1_v2", VirtualMachineConfiguration: new VirtualMachineConfiguration( imageReference: new ImageReference( publisher: "MicrosoftWindowsServer", offer: "WindowsServer", sku: "2019-datacenter-core", version: "latest"), nodeAgentSkuId: "batch.node.windows amd64"); pool.AutoScaleEnabled = true; pool.AutoScaleFormula = "$TargetDedicatedNodes = (time().weekday == 1 ? 5:1);"; pool.AutoScaleEvaluationInterval = TimeSpan.FromMinutes(30); await pool.CommitAsync();
# Create a pool; specify configuration new_pool = batch.models.PoolAddParameter( id="autoscale-enabled-pool", virtual_machine_configuration=batchmodels.VirtualMachineConfiguration( image_reference=batchmodels.ImageReference( publisher="Canonical", offer="UbuntuServer", sku="20.04-LTS", version="latest" ), node_agent_sku_id="batch.node.ubuntu 20.04"), vm_size="STANDARD_D1_v2", target_dedicated_nodes=0, target_low_priority_nodes=0 ) batch_service_client.pool.add(new_pool) # Add the pool to the service client formula = """$curTime = time(); $workHours = $curTime.hour >= 8 && $curTime.hour < 18; $isWeekday = $curTime.weekday >= 1 && $curTime.weekday <= 5; $isWorkingWeekdayHour = $workHours && $isWeekday; $TargetDedicated = $isWorkingWeekdayHour ? 20:10;"""; # Enable autoscale; specify the formula response = batch_service_client.pool.enable_auto_scale(pool_id, auto_scale_formula=formula, auto_scale_evaluation_interval=datetime.timedelta(minutes=10), pool_enable_auto_scale_options=None, custom_headers=None, raw=False)
Last execution: 10/14/2016 18:36:43 Result: $TargetDedicatedNodes=10; $NodeDeallocationOption=requeue; $curTime=2016-10-14T18:36:43.282Z; $isWeekday=1; $isWorkingWeekdayHour=0; $workHours=0 Error:
{ "id": "poolId", "timestamp": "2020-09-21T23:41:36.750Z", "formula": "...", "results": "$TargetDedicatedNodes=10;$NodeDeallocationOption=requeue;$curTime=2016-10-14T18:36:43.282Z;$isWeekday=1;$isWorkingWeekdayHour=0;$workHours=0", "error": { "code": "", "message": "", "values": [] } }
// Get pending tasks for the past 15 minutes. $samples = $PendingTasks.GetSamplePercent(TimeInterval_Minute * 15); // If you have fewer than 70 percent data points, use the last sample point, // otherwise use the maximum of last sample point and the history average. $tasks = $samples < 70 ? max(0,$PendingTasks.GetSample(1)) : max( $PendingTasks.GetSample(1), avg($PendingTasks.GetSample(TimeInterval_Minute * 15))); // If number of pending tasks is not 0, set targetVM to pending tasks, otherwise // half of current dedicated. $targetVMs = $tasks > 0? $tasks:max(0, $TargetDedicatedNodes/2); // The pool size is capped at 20, if target VM value is more than that, set it // to 20. This value should be adjusted according to your use case. $TargetDedicatedNodes = max(0, min($targetVMs, 20)); // Set node deallocation mode - let running tasks finish before removing a node $NodeDeallocationOption = taskcompletion;
// Determine whether 70 percent of the samples have been recorded in the past // 15 minutes; if not, use last sample $samples = $ActiveTasks.GetSamplePercent(TimeInterval_Minute * 15); $tasks = $samples < 70 ? max(0,$ActiveTasks.GetSample(1)) : max( $ActiveTasks.GetSample(1),avg($ActiveTasks.GetSample(TimeInterval_Minute * 15))); // Set the number of nodes to add to one-fourth the number of active tasks // (the TaskSlotsPerNode property on this pool is set to 4, adjust // this number for your use case) $cores = $TargetDedicatedNodes * 4; $extraVMs = (($tasks - $cores) + 3) / 4; $targetVMs = ($TargetDedicatedNodes + $extraVMs); // Attempt to grow the number of compute nodes to match the number of active // tasks, with a maximum of 3 $TargetDedicatedNodes = max(0,min($targetVMs,3)); // Keep the nodes active until the tasks finish $NodeDeallocationOption = taskcompletion;