Closed ArmaanMcleod closed 3 years ago
Something like this should work:
function VisitAKSCluster {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
[PSObject]$Resource,
[Parameter(Mandatory = $True)]
[Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer]$Context
)
process {
$resources = @();
if ($Resource.Properties.networkProfile.networkPlugin -eq 'azure') {
$nodePools = @($Resource.Properties.agentPoolProfiles);
foreach ($nodePool in $nodePools) {
$vnetId = $nodePool.vnetSubnetID;
$resources += GetResourceById -ResourceId $vnetId -ApiVersion '2020-05-01' -Context $Context;
}
}
$Resource | Add-Member -MemberType NoteProperty -Name resources -Value $resources -PassThru;
}
}
@ArmaanMcleod Thanks. Makes sense to me. I'll review the PR.
Description of the issue
When running
Export-AzRuleData
on a RG with my AKS cluster that is using kubenet instead of Azure CNI, the following error happens:To Reproduce
Steps to reproduce the issue:
Expected behaviour
Not error out for invalid
vnetSubnetID
property.I think this should check if
properties.networkProfile.networkPlugin
is not set tokubenet
before adding this property. Could also just check if it set toazure
.https://docs.microsoft.com/en-us/azure/templates/microsoft.containerservice/managedclusters?tabs=json#containerservicenetworkprofile-object
Let me know if I'm not running something properly here 😄 .