{"record":{"id":"9c73fe8162b4e07f","repo":"microsoft/aspire","slug":"expected-ingressprofile-to-be-a-azure-provisioning","errorCode":null,"errorMessage":"Expected IngressProfile to be a Azure.Provisioning.ContainerService.ManagedClusterIngressProfile but found {ipInstance.GetType().FullName}.","messagePattern":"Expected IngressProfile to be a Azure\\.Provisioning\\.ContainerService\\.ManagedClusterIngressProfile but found (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs","lineNumber":178,"sourceCode":"        // ContainerServiceManagedCluster.Properties is internal and exposes the\n        // ManagedClusterProperties complex object that owns IngressProfile (also internal).\n        var clusterPropsProp = typeof(ContainerServiceManagedCluster).GetProperty(\n            \"Properties\",\n            BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)\n            ?? throw new InvalidOperationException(\"ContainerServiceManagedCluster.Properties not found via reflection. The Azure.Provisioning surface may have changed; review AksPreviewIngressProfileInjector.\");\n        var clusterProps = clusterPropsProp.GetValue(aks)\n            ?? throw new InvalidOperationException(\"ContainerServiceManagedCluster.Properties returned null.\");\n\n        var ipProp = clusterProps.GetType().GetProperty(\n            \"IngressProfile\",\n            BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)\n            ?? throw new InvalidOperationException(\"ManagedClusterProperties.IngressProfile not found via reflection. The Azure.Provisioning surface may have changed; review AksPreviewIngressProfileInjector.\");\n        var ipInstance = ipProp.GetValue(clusterProps)\n            ?? throw new InvalidOperationException(\"ManagedClusterProperties.IngressProfile was null even after assigning IngressWebAppRouting; the Azure.Provisioning lazy-initialization behavior may have changed.\");\n\n        if (ipInstance.GetType().FullName != IngressProfileTypeFullName)\n        {\n            throw new InvalidOperationException($\"Expected IngressProfile to be a {IngressProfileTypeFullName} but found {ipInstance.GetType().FullName}.\");\n        }\n\n        return ipInstance;\n    }\n}\n","sourceCodeStart":160,"sourceCodeEnd":184,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs#L160-L184","documentation":"The injector successfully fetched a non-null IngressProfile instance via reflection, but its runtime type's full name does not equal the expected 'Azure.Provisioning.ContainerService.ManagedClusterIngressProfile'. This is a guard against the Azure.Provisioning surface changing shape (renamed/replaced internal type), since the injector then invokes DefineProperty<T> on that instance by reflection.","triggerScenarios":"Running the injector against an Azure.Provisioning.ContainerService version where ManagedClusterProperties.IngressProfile is typed as a different (renamed, new assembly, or replaced) type than Azure.Provisioning.ContainerService.ManagedClusterIngressProfile, or where assembly-identity differences yield a distinct FullName.","commonSituations":"Package version drift after upgrading Azure.Provisioning.*; binding a different Azure.Provisioning.ContainerService assembly via transitive dependency resolution; Microsoft regenerating the SDK with a renamed internal type.","solutions":["Verify the resolved Azure.Provisioning.ContainerService assembly and version; pin the known-good version (1.0.0-beta.6)","Inspect the actual typeFullName in the message; if the SDK renamed the type, update the IngressProfileTypeFullName constant or replace the injector with the public typed API","If the type is now public, migrate away from reflection entirely (aspire issue 17060)","Check for conflicting Azure.Provisioning.* versions with a NuGet graph audit (dotnet list package --include-transitive)"],"exampleFix":"// before\nprivate const string IngressProfileTypeFullName = \"Azure.Provisioning.ContainerService.ManagedClusterIngressProfile\";\n// after (if the SDK renamed the internal type)\nprivate const string IngressProfileTypeFullName = \"Azure.Provisioning.ContainerService.ManagedClusterIngressProfileVNext\"; // match the new SDK type","handlingStrategy":"type-guard","validationCode":"static bool HasExpectedIngressProfile(ContainerServiceManagedCluster aks)\n{\n    var props = typeof(ContainerServiceManagedCluster).GetProperty(\"Properties\", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(aks);\n    var ip = props?.GetType().GetProperty(\"IngressProfile\", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(props);\n    return ip?.GetType().FullName == \"Azure.Provisioning.ContainerService.ManagedClusterIngressProfile\";\n}","typeGuard":"static object? GetIngressProfileOrNull(ContainerServiceManagedCluster aks)\n    => typeof(ContainerServiceManagedCluster).GetProperty(\"Properties\", BindingFlags.NonPublic | BindingFlags.Instance) is { } pp\n       && pp.GetValue(aks) is { } props\n       && props.GetType().GetProperty(\"IngressProfile\", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(props) is { } ip\n       && ip.GetType().FullName == \"Azure.Provisioning.ContainerService.ManagedClusterIngressProfile\"\n        ? ip : null;","tryCatchPattern":"try\n{\n    AksPreviewIngressProfileInjector.Inject(aks, gatewayApi: true, applicationLoadBalancer: true);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Expected IngressProfile to be a\"))\n{\n    // Log the actual type from ex.Message and pin or adapt to the new Azure.Provisioning version.\n}","preventionTips":["Run Bicep emission snapshot tests on every Azure.Provisioning.* version bump","Avoid mixing Azure.Provisioning.* package versions across the dependency graph","Prefer migrating to the public typed API as soon as ManagedClusterIngressProfile becomes public"],"tags":["azure","aks","reflection","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}