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
⚠️
windows_first
Summary:
The documentation provides parallel examples for both Azure CLI (Bash) and Azure PowerShell, but there are several signs of Windows bias. PowerShell is given equal or sometimes more detailed treatment, and Windows-specific tools and APIs (such as CommandLineToArgvW and Connect-AzAccount) are referenced without Linux equivalents. The documentation assumes familiarity with PowerShell patterns and Windows-centric APIs, and sometimes mentions Windows/PowerShell tools before or more prominently than their Linux/Bash counterparts.
Recommendations:
- Where Windows-specific APIs or tools are referenced (e.g., CommandLineToArgvW, Connect-AzAccount), provide Linux or cross-platform equivalents or clarify that these are implementation details not relevant to script authors.
- Ensure that CLI/Bash examples are always presented first or in parallel with PowerShell examples, especially in introductory or summary sections.
- Where PowerShell-specific troubleshooting or scripting patterns are discussed (e.g., $ErrorActionPreference, Start-Sleep), provide Bash/Linux equivalents (e.g., set -e, sleep) and explain their usage.
- Clarify that both Bash and PowerShell scripts run in Linux-based containers by default, and highlight any cross-platform considerations.
- Avoid referencing Windows-only concepts or APIs unless strictly necessary, and always provide context for users on non-Windows platforms.
- Consider adding a section explicitly addressing cross-platform scripting best practices and differences between Bash and PowerShell in the Azure deployment script context.
Create pull request
Flagged Code Snippets
resource <symbolic-name> 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: '<resource-name>'
location: resourceGroup().location
tags: {}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'<user-assigned-identity-id>': {}
}
}
kind: 'AzurePowerShell'
properties: {
storageAccountSettings: {
storageAccountName: '<storage-account-name>'
storageAccountKey: '<storage-account-key>'
}
containerSettings: {
containerGroupName: '<container-group-name>'
subnetIds: [
{
id: '<subnet-id>'
}
]
}
environmentVariables: []
azPowerShellVersion: '10.0'
arguments: '<script-arguments>'
scriptContent: '''<azure-cli-or-azure-powershell-script>''' // or primaryScriptUri: 'https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/main/samples/deployment-script/inlineScript.ps1'
supportingScriptUris: []
timeout: 'P1D'
cleanupPreference: 'OnSuccess'
retentionInterval: 'P1D'
forceUpdateTag: '1'
}
}
resource <symbolic-name> 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: '<resource-name>'
location: resourceGroup().location
tags: {}
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'<user-assigned-identity-id>': {}
}
}
kind: 'AzureCLI'
properties: {
storageAccountSettings: {
storageAccountName: '<storage-account-name>'
storageAccountKey: '<storage-account-key>'
}
containerSettings: {
containerGroupName: '<container-group-name>'
subnetIds: [
{
id: '<subnet-id>'
}
]
}
environmentVariables: []
azCliVersion: '2.52.0'
arguments: '<script-arguments>'
scriptContent: '''<azure-cli-or-azure-powershell-script>''' // or primaryScriptUri: 'https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/main/samples/deployment-script/inlineScript.ps1'
supportingScriptUris: []
timeout: 'P1D'
cleanupPreference: 'OnSuccess'
retentionInterval: 'P1D'
forceUpdateTag: '1'
}
}
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'passEnvVariablesPS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
environmentVariables: [
{
name: 'UserName'
value: 'jdole'
}
{
name: 'Password'
secureValue: 'jDolePassword'
}
]
scriptContent: '''
Write-output "Username is :$Username"
Write-output "Password is: $Password"
'''
retentionInterval: 'P1D'
}
}
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'listEnvVariablesPS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
scriptContent: '''
Write-Output "AZ_SCRIPTS_AZURE_ENVIRONMENT is : ${Env:AZ_SCRIPTS_AZURE_ENVIRONMENT}"
Write-Output "AZ_SCRIPTS_CLEANUP_PREFERENCE is : ${Env:AZ_SCRIPTS_CLEANUP_PREFERENCE}"
Write-Output "AZ_SCRIPTS_OUTPUT_PATH is : ${Env:AZ_SCRIPTS_OUTPUT_PATH}"
Write-Output "AZ_SCRIPTS_PATH_INPUT_DIRECTORY is : ${Env:AZ_SCRIPTS_PATH_INPUT_DIRECTORY}"
Write-Output "AZ_SCRIPTS_PATH_OUTPUT_DIRECTORY is : ${Env:AZ_SCRIPTS_PATH_OUTPUT_DIRECTORY}"
Write-Output "AZ_SCRIPTS_PATH_USER_SCRIPT_FILE_NAME is : ${Env:AZ_SCRIPTS_PATH_USER_SCRIPT_FILE_NAME}"
Write-Output "AZ_SCRIPTS_PATH_PRIMARY_SCRIPT_URI_FILE_NAME is : ${Env:AZ_SCRIPTS_PATH_PRIMARY_SCRIPT_URI_FILE_NAME}"
Write-Output "AZ_SCRIPTS_PATH_SUPPORTING_SCRIPT_URI_FILE_NAME is : ${Env:AZ_SCRIPTS_PATH_SUPPORTING_SCRIPT_URI_FILE_NAME}"
Write-Output "AZ_SCRIPTS_PATH_SCRIPT_OUTPUT_FILE_NAME is : ${Env:AZ_SCRIPTS_PATH_SCRIPT_OUTPUT_FILE_NAME}"
Write-Output "AZ_SCRIPTS_PATH_EXECUTION_RESULTS_FILE_NAME is : ${Env:AZ_SCRIPTS_PATH_EXECUTION_RESULTS_FILE_NAME}"
Write-Output "AZ_SCRIPTS_USER_ASSIGNED_IDENTITY is : ${Env:AZ_SCRIPTS_USER_ASSIGNED_IDENTITY}"
'''
retentionInterval: 'P1D'
}
}
param name string = '\\"John Dole\\"'
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'inlinePS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
arguments: '-name ${name}'
scriptContent: '''
param([string] $name)
$ErrorActionPreference = 'Stop'
$output = "Hello {0}" -f $name
Write-Output "Output is: '$output'."
'''
retentionInterval: 'P1D'
}
}
param([string] $name)
$output = "Hello {0}" -f $name
Write-Output "Output is: '$output'."
param name string = '\\"John Dole\\"'
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'loadTextContentPS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
arguments: '-name ${name}'
scriptContent: loadTextContent('./scripts/hello.ps1')
retentionInterval: 'P1D'
}
}
param name string = '\\"John Dole\\"'
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'externalScriptPS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
primaryScriptUri: 'https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/main/samples/deployment-script/hello.ps1'
arguments: '-name ${name}'
retentionInterval: 'P1D'
}
}
param name string = '\\"John Dole\\"'
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'supportingScriptPS'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
arguments: '-name ${name}'
scriptContent: '''
param([string] $name)
$output = "Hello {0}" -f $name
Write-Output "Output is: '$output'."
./hello.ps1 -name $name
'''
supportingScriptUris: [
'https://raw.githubusercontent.com/Azure/azure-docs-bicep-samples/master/samples/deployment-script/hello.ps1'
]
retentionInterval: 'P1D'
}
}
param identity string
param location string = resourceGroup().location
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'listKvPS'
location: location
kind: 'AzurePowerShell'
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${identity}': {}
}
}
properties: {
azPowerShellVersion: '10.0'
scriptContent: '''
$kvs=Get-AzKeyVault
$output = @()
foreach($kv in $kvs){
$newKv = @{
id = $kv.resourceId
}
$output = $output + $newKv
}
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs["kvs"] = $output
'''
retentionInterval: 'P1D'
}
}
output result object = deploymentScript.properties.outputs
param name string = '\\"John Dole\\"'
param location string = resourceGroup().location
resource deploymentScript1 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'outputPS1'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
arguments: '-name ${name}'
scriptContent: '''
param([string] $name)
$output = 'Hello {0}' -f $name
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['text'] = $output
'''
retentionInterval: 'P1D'
}
}
resource deploymentScript2 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'outputPS2'
location: location
kind: 'AzurePowerShell'
properties: {
azPowerShellVersion: '10.0'
arguments: '-textToEcho \\"${deploymentScript1.properties.outputs.text}\\"'
scriptContent: '''
param([string] $textToEcho)
Write-Output $textToEcho
'''
retentionInterval: 'P1D'
}
}