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 provides both Azure CLI and Azure PowerShell examples for all queries, but it demonstrates a subtle Windows bias. PowerShell examples are always present and sometimes described in more detail (e.g., explanation of ConvertTo-Json and object depth). The PowerShell examples use Windows-specific scripting patterns and variable handling. In the multi-step public IP address example, the Azure CLI solution uses Unix tools (awk, sed, tail), but there is no explicit mention of Linux or cross-platform compatibility, nor any Windows Command Prompt or PowerShell equivalents for those CLI steps. The JSON output examples are based on Windows VMs (e.g., osType: Windows, WindowsServer images), and there is no mention of Linux VM properties or images. There are no explicit Linux shell (bash) or cross-platform scripting examples, and the documentation assumes familiarity with Windows-centric tools and patterns.
Recommendations:
- Add Linux/Unix shell (bash) examples for scripting steps, especially where Azure CLI is used with Unix tools (awk, sed, tail).
- Include Windows Command Prompt or PowerShell equivalents for Azure CLI scripting steps to ensure parity.
- Provide examples and JSON output for both Windows and Linux virtual machines (e.g., osType: Linux, imageReference for Ubuntu or CentOS).
- Explicitly mention cross-platform compatibility of Azure CLI and how to adapt scripts for different environments.
- Balance explanations and notes between Azure CLI and PowerShell, ensuring neither is favored in depth or detail.
- Where possible, use cross-platform scripting constructs or highlight differences for users on Windows, Linux, and macOS.
Create pull request
Flagged Code Snippets
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | limit 1").Data | ConvertTo-Json -Depth 100
[
{
"id": "/subscriptions/<subscriptionId>/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/ContosoVM1",
"kind": "",
"location": "westus2",
"managedBy": "",
"name": "ContosoVM1",
"plan": {},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_B2s"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/<subscriptionId>/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/contosovm2222",
"resourceGroup": "MyResourceGroup"
}
]
},
"osProfile": {
"adminUsername": "localAdmin",
"computerName": "ContosoVM1",
"secrets": [],
"windowsConfiguration": {
"enableAutomaticUpdates": true,
"provisionVMAgent": true
}
},
"provisioningState": "Succeeded",
"storageProfile": {
"dataDisks": [],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"diskSizeGB": 127,
"managedDisk": {
"id": "/subscriptions/<subscriptionId>/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/disks/ContosoVM1_OsDisk_1_11111111111111111111111111111111",
"resourceGroup": "MyResourceGroup",
"storageAccountType": "Premium_LRS"
},
"name": "ContosoVM1_OsDisk_1_11111111111111111111111111111111",
"osType": "Windows"
}
},
"vmId": "11111111-1111-1111-1111-111111111111"
},
"resourceGroup": "MyResourceGroup",
"sku": {},
"subscriptionId": "<subscriptionId>",
"tags": {},
"type": "microsoft.compute/virtualmachines"
}
]
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location").Data | ConvertTo-Json
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/virtualMachines' and properties.hardwareProfile.vmSize == 'Standard_B2s' | project name, resourceGroup").Data | ConvertTo-Json
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/virtualmachines' and properties.hardwareProfile.vmSize == 'Standard_B2s' | extend disk = properties.storageProfile.osDisk.managedDisk | where disk.storageAccountType == 'Premium_LRS' | project disk.id").Data | ConvertTo-Json
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/disks' and id == '/subscriptions/<subscriptionId>/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/disks/ContosoVM1_OsDisk_1_11111111111111111111111111111111'").Data | ConvertTo-Json
# Use Resource Graph to get all NICs and store in the $nics variable
$nics = (Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project nic = tostring(properties['networkProfile']['networkInterfaces'][0]['id']) | where isnotempty(nic) | distinct nic | limit 20").Data
# Review the output of the query stored in the variable
$nics.nic
# Use Resource Graph with the $nics variable to get all related public IP addresses and store in $ips variable
$ips = (Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Network/networkInterfaces' | where id in ('$($nics.nic -join "','")') | project publicIp = tostring(properties['ipConfigurations'][0]['properties']['publicIPAddress']['id']) | where isnotempty(publicIp) | distinct publicIp").Data
# Review the output of the query stored in the variable
$ips.publicIp
# Use Resource Graph with the $ips variable to get the IP address of the public IP address resources
(Search-AzGraph -Query "Resources | where type =~ 'Microsoft.Network/publicIPAddresses' | where id in ('$($ips.publicIp -join "','")') | project ip = tostring(properties['ipAddress']) | where isnotempty(ip) | distinct ip").Data | ConvertTo-Json