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:
⚠️
powershell_heavy
⚠️
windows_tools
⚠️
missing_linux_example
⚠️
windows_first
Summary:
The documentation page is heavily focused on Azure PowerShell cmdlets and provides only PowerShell-based examples and recommendations. It exclusively references Windows-centric tools and patterns (such as PowerShell cmdlets like Add-AzAccount, Disable-AzContextAutosave, and Get-AzVM) without mentioning or providing equivalent guidance for Linux users or those using Azure CLI, Python SDK, or other cross-platform tools. There are no Bash, Azure CLI, or non-Windows scripting examples, and the terminology assumes a PowerShell context throughout.
Recommendations:
- Add equivalent examples using Azure CLI (az) commands for context management and resource access, showing how to handle context switching in Bash or other shells.
- Include a section or code snippets for Python SDK or REST API usage to demonstrate cross-platform automation approaches.
- Explicitly mention that the guidance applies to PowerShell and provide links or references to Linux or cross-platform alternatives.
- Rephrase sections to use neutral terminology (e.g., 'script' instead of 'runbook' where appropriate) and clarify when a step is PowerShell-specific.
- Ensure that troubleshooting and error messages include examples that could be encountered when using non-PowerShell tools.
Create pull request
Flagged Code Snippets
# Ensures you do not inherit an AzContext in your runbook
Disable-AzContextAutosave -Scope Process
# Connect to Azure with system-assigned managed identity
$AzureContext = (Connect-AzAccount -Identity).context
# set and store context
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext
# Pass context object - even though the context had just been set
# This is the step that guarantees the context will not be switched.
Get-AzVM -ResourceGroupName "resourceGroupName" -DefaultProfile $AzureContext | Select Name
Get-AzureRmResource : Resource group "SomeResourceGroupName" could not be found.
... resources = Get-AzResource -ResourceGroupName $group.ResourceGro ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzResource], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet
Get-AzVM : The client '<clientid>' with object id '<objectid>' does not have authorization to perform action 'Microsoft.Compute/virtualMachines/read' over scope '/subscriptions/<subscriptionIdOfSubscriptionWhichDoesntContainTheVM>/resourceGroups/REsourceGroupName/providers/Microsoft.Compute/virtualMachines/VMName '.
ErrorCode: AuthorizationFailed
StatusCode: 403
ReasonPhrase: Forbidden Operation
ID : <AGuidRepresentingTheOperation> At line:51 char:7 + $vm = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $UNBV... +