Backup – Azure Automation Connections (Runbooks)
Nachfolgend findest du ein PowerShell-Skript, mit dem du ein Backup der Azure Automation Connection in eine CSV-Datei erstellen kannst, die du in einem anderen Azure Automation Account restore kannst.
<#
Backup Azure Automation Connections to another account
#>
## Source Automation Account
$ResourceGroup1 = "your data"
$AutomationAccount1 = "your data"
##Get Date
$date = get-date -format "yyyyMMdd"
## Export CSV Name
$ExportCSVName = "c:\TMP\BackupAutomationConnections_$($date).csv"
## Connect to Azure AD by Managed Identity
Connect-AzAccount
$Results = New-Object 'System.Collections.Generic.List[System.Object]'
$Connects = Get-AzAutomationConnection -ResourceGroupName $ResourceGroup1 -AutomationAccountName $AutomationAccount1
$Connects | ForEach-Object {
$Conn = Get-AzAutomationConnection -ResourceGroupName $ResourceGroup1 -AutomationAccountName $AutomationAccount1 -Name $_.Name
$Result = [PSCustomObject]@{'Name' = $_.Name; 'SubscriptionId' = $Conn.FieldDefinitionValues.SubscriptionId; 'TenantId' = $Conn.FieldDefinitionValues.TenantId; 'ApplicationId' = $Conn.FieldDefinitionValues.ApplicationId; 'CertificateThumbprint' = $Conn.FieldDefinitionValues.CertificateThumbprint}
$Results.add($Result)
}
$Results | Export-Csv -Path $ExportCSVName -Notype -Append
DisConnect-AzAccount