Closed TheKingIGER closed 5 years ago
I have looked at the behavior and could reproduce the error.
In my opinion there is something wrong with the response type because the Type
System.Linq.Enumerable+WhereSelectEnumerableIterator
indicates a Linq query which is not transacted succesfully.
If we look at the Code in the GetAZureRmAks.cs
we will find the following code at Line 92:
var kubeClusters = string.IsNullOrEmpty(ResourceGroupName)
? Client.ManagedClusters.List()
: Client.ManagedClusters.ListByResourceGroup(ResourceGroupName);
WriteObject(kubeClusters.Select(PSMapper.Instance.Map<PSKubernetesCluster>));
I am a bit confused about the Select
Statement in the Write-Object
call. The PSMapper does not look like a valid Lambda expression in my opinion.
Wouldn't something like the following code also do the job or is there a specific reason for running a Select before mapping the IPage<ManagedCluster>
to PSKubernetesCluster
?
var kubeClusters = string.IsNullOrEmpty(ResourceGroupName)
? Client.ManagedClusters.List()
: Client.ManagedClusters.ListByResourceGroup(ResourceGroupName);
WriteObject(PSMapper.Instance.Map<PSKubernetesCluster>(kubeClusters));
@TheKingIGER thanks for filing this issue -- I have opened a PR with the fix here
Is the issue fixed? I am able to reproduce the issue.
Description
I found some strange behavior of the Get-AzAks Cmdlet. Everthing is descripted in the Steps to reproduce section
Steps to reproduce
Using the .Count property of the
$aks
variable the output will be 1 1 instead of 2When using an index (
$aks[0]
), the output will be all objects from the Array.The return type of the Commands is a little bit strange. It's not a
System.Object[]
like other cmdlets (e.g.Get-AzVm
).Working Workarounds:
$aks.count -> ($aks.count).Count or ($aks.name).Count
$aks[0] -> foreach
Environment data
Module versions
Debug output
Error output