Home > Software design >  Array is of fixed size (imported from JSON file object)
Array is of fixed size (imported from JSON file object)

Time:09-13

I'm trying to create a new JSON deployment file from an existing object.. but the new object wont allow me to add additional parameters

Export-AzResourceGroup -ResourceGroupName $InputObject.ResourceGroupName -Resource $InputObject.id -IncludeParameterDefaultValue -IncludeComments -Path ./InputObject.json

$NewObject=Get-Content -Raw ./InputObject.json | ConvertFrom-Json  

$NewObject.resources.zones={1,2,3}

#InvalidOperation: The property 'zones' cannot be found on this object. Verify that the property exists and can be set.

$newObject.resources.Add('zones')

MethodInvocationException: Exception calling "Add" with "1" argument(s): "Collection was of a fixed size."

How to add additional resource entries into the array?

(goal is to export an existing AppGateway, delete it and recreate it with zone redundancy)

CodePudding user response:

Check Types of the items you get .

See <<Object>>.GetType() , System.Collections.Hashtable , Add-Member and System.Collections.Generic.List[object] .

  • Related