Azure/AzLoadBalancerMigration

Backup of VMSS Fails when VMSS has Object in Extension Settings on PS 5.1

Closed this issue · 5 comments

I get an error when the VMSS backup file is being created:

2023-01-20 06:06:46.3044 [Error] - [BackupBasicLoadBalancer] An error occured while exporting the VMSS '' for backup purposes. Error: Exception calling "Serialize" with "3" argument(s): "The collection type 'System.Object' on 'Microsoft.Azure.Commands.Compute.Automation.Models.PSVirtualMachineScaleSetExtension.Settings' is not supported."

PSVirtualMachineScaleSetExtension.Settings does indeed appear to be an object: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.commands.compute.models.psvirtualmachinescalesetextension.settings?view=az-ps-latest

Incidentally, the error message does not display the VMSS name since the $vmssName variable is never set:

$message = "[BackupBasicLoadBalancer] An error occured while exporting the VMSS '$($vmssName)' for backup purposes. Error: $_"

Hi again @bjh1977! Can you confirm the version of the module you are running and the PowerShell version? We switched the .split() to -split in the module a couple versions back, making it case-insensitive and added some additional checks for a similar issue.

With the module imported, running get-module should show you the module version. $PSVersionTable will show the PowerShell version.

On the issue serializing the extension object, I'll need to look into it. There's a max depth option on the serializer which may be sufficient (since we don't care about the extensions), but I'd also need to check that is compatible with PS 5.1.

Thanks!

WORKAROUND:
This issue is specific to PowerShell 5.1; use PowerShell 7 as a workaround. The Azure Cloud Shell is an easy environment for execution which runs PowerShell 7

@bjh1977

Appears to be fixed by 88f61d7

User reported still an issue: #47

Added logic to catch this exception and direct user to PS 7 in #48