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
⚠️
missing_linux_example
⚠️
windows_tools
Summary:
The documentation provides only Azure PowerShell examples for managing and assigning roles to Azure savings plans, with no mention of equivalent Azure CLI or cross-platform scripting options. This approach assumes the use of PowerShell, which is traditionally associated with Windows environments, and omits guidance for users on Linux or macOS who may prefer or require Azure CLI or bash scripting.
Recommendations:
- Add equivalent Azure CLI examples for all PowerShell scripts provided, ensuring Linux and macOS users have clear, supported instructions.
- Explicitly state that PowerShell Core is cross-platform, if PowerShell must be used, and provide installation links for Linux/macOS.
- Where possible, provide REST API examples using curl or similar tools to support automation from any OS.
- Review the documentation for other areas where Windows-centric tools or terminology are used and provide Linux/macOS alternatives.
- Consider a section or note at the start of the scripting section indicating which tools are cross-platform and which are Windows-only.
Create pull request
Flagged Code Snippets
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Administrator"
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Reader"
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
$response = Invoke-AzRestMethod -Path /providers/Microsoft.BillingBenefits/savingsPlans?api-version=2022-11-01 -Method GET
$responseJSON = $response.Content | ConvertFrom-JSON
$savingsPlanObjects = $responseJSON.value
foreach ($savingsPlan in $savingsPlanObjects)
{
$savingsPlanOrderId = $savingsPlan.id.substring(0, 84)
Write-Host "Assigning Owner role assignment to "$savingsPlanOrderId
New-AzRoleAssignment -Scope $savingsPlanOrderId -ObjectId <ObjectId> -RoleDefinitionName Owner
}
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Administrator"
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Contributor"
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Reader"
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
$response = Invoke-AzRestMethod -Path /providers/Microsoft.BillingBenefits/savingsPlans?api-version=2022-11-01 -Method GET
$responseJSON = $response.Content | ConvertFrom-JSON
$savingsPlanObjects = $responseJSON.value
foreach ($savingsPlan in $savingsPlanObjects)
{
$savingsPlanOrderId = $savingsPlan.id.substring(0, 84)
Write-Host "Assigning Owner role assignment to "$savingsPlanOrderId
New-AzRoleAssignment -Scope $savingsPlanOrderId -ObjectId <ObjectId> -RoleDefinitionName Owner
}
Import-Module Az.Accounts
Import-Module Az.Resources
Connect-AzAccount -Tenant <TenantId>
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Contributor"