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 page exclusively provides PowerShell-based examples and scripts for integrating Azure Automation runbooks into Site Recovery recovery plans. There are no examples or guidance for users who may prefer or require Linux-based scripting (e.g., Bash, Python) or cross-platform approaches. All module references and code samples are tailored to the Azure PowerShell module ecosystem, which is most familiar to Windows users. There is no mention of Linux tools, shell scripting, or how to achieve similar automation using non-Windows environments.
Recommendations:
- Provide equivalent examples using Bash or Python runbooks, especially for common automation tasks.
- Mention and link to documentation for cross-platform Azure Automation runbooks (e.g., Python, PowerShell Core).
- Clarify which steps or scripts are Windows-specific and offer Linux alternatives where possible.
- Include guidance on using Azure CLI (az) commands in runbooks for users on Linux or macOS.
- Reference the ability to use hybrid worker groups that can run scripts on Linux machines, and provide examples.
Create pull request
Flagged Code Snippets
workflow AddPublicIPAndNSG {
param (
[parameter(Mandatory=$false)]
[Object]$RecoveryPlanContext
)
$RPName = $RecoveryPlanContext.RecoveryPlanName
}
Connect-AzureRmAccount
$sub = Get-AzureRmSubscription -Name <SubscriptionName>
$sub | Select-AzureRmSubscription
param (
[parameter(Mandatory=$false)]
[Object]$RecoveryPlanContext
)
$VMinfo = $RecoveryPlanContext.VmMap | Get-Member | Where-Object MemberType -EQ NoteProperty | select -ExpandProperty Name
$vmMap = $RecoveryPlanContext.VmMap
foreach($VMID in $VMinfo)
{
$VM = $vmMap.$VMID
if( !(($VM -eq $Null) -Or ($VM.ResourceGroupName -eq $Null) -Or ($VM.RoleName -eq $Null))) {
#this check is to ensure that we skip when some data is not available else it will fail
Write-output "Resource group name ", $VM.ResourceGroupName
Write-output "Rolename " = $VM.RoleName
}
}
$NSGValue = $RecoveryPlanContext.RecoveryPlanName + "-NSG"
$NSGRGValue = $RecoveryPlanContext.RecoveryPlanName + "-NSGRG"
$NSGnameVar = Get-AutomationVariable -Name $NSGValue
$RGnameVar = Get-AutomationVariable -Name $NSGRGValue
InlineScript {
if (($Using:NSGname -ne $Null) -And ($Using:NSGRGname -ne $Null)) {
$NSG = Get-AzureRmNetworkSecurityGroup -Name $Using:NSGname -ResourceGroupName $Using:NSGRGname
Write-output $NSG.Id
#Apply the NSG to a network interface
#$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName TestRG -Name TestVNet
#Set-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name FrontEnd `
# -AddressPrefix 192.168.1.0/24 -NetworkSecurityGroup $NSG
}
}
$VMDetails = @{"VMGUID"=@{"ResourceGroupName"="RGNameOfNSG";"NSGName"="NameOfNSG"};"VMGUID2"=@{"ResourceGroupName"="RGNameOfNSG";"NSGName"="NameOfNSG"}}
New-AzureRmAutomationVariable -ResourceGroupName <RG of Automation Account> -AutomationAccountName <AA Name> -Name <RecoveryPlanName> -Value $VMDetails -Encrypted $false
$VMDetailsObj = (Get-AzAutomationVariable -Name $RecoveryPlanContext.RecoveryPlanName).ToObject([hashtable])
$VMinfo = $RecoveryPlanContext.VmMap | Get-Member | Where-Object MemberType -EQ NoteProperty | select -ExpandProperty Name
$vmMap = $RecoveryPlanContext.VmMap
foreach ($VMID in $VMinfo) {
$VMDetails = $VMDetailsObj[$VMID].ToObject([hashtable]);
Write-output $VMDetails
if ($VMDetails -ne $Null) { #If the VM exists in the context, this will not be Null
$VM = $vmMap.$VMID
# Access the properties of the variable
$NSGname = $VMDetails.NSGName
$NSGRGname = $VMDetails.NSGResourceGroupName
# Add code to apply the NSG properties to the VM
}
}