{"record":{"id":"cf6eef29d143bf29","repo":"microsoft/aspire","slug":"managedclusterproperties-ingressprofile-was-null-even-after","errorCode":null,"errorMessage":"ManagedClusterProperties.IngressProfile was null even after assigning IngressWebAppRouting; the Azure.Provisioning lazy-initialization behavior may have changed.","messagePattern":"ManagedClusterProperties\\.IngressProfile was null even after assigning IngressWebAppRouting; the Azure\\.Provisioning lazy-initialization behavior may have changed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs","lineNumber":174,"sourceCode":"    }\n\n    private static object GetIngressProfileInstance(ContainerServiceManagedCluster aks)\n    {\n        // 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":156,"sourceCodeEnd":184,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs#L156-L184","documentation":"AksPreviewIngressProfileInjector uses reflection to reach the internal ManagedClusterProperties.IngressProfile object on a ContainerServiceManagedCluster. It first assigns IngressWebAppRouting, which is expected to lazily create the internal IngressProfile instance. This error means that even after that assignment, the reflected IngressProfile property returned null, i.e. the Azure.Provisioning lazy-initialization contract this injector relies on no longer holds.","triggerScenarios":"Calling AksPreviewIngressProfileInjector.Inject (directly or via AKS gateway-API / application-load-balancer configuration) with a Azure.Provisioning.ContainerService version where setting ContainerServiceManagedCluster.IngressWebAppRouting no longer eagerly initializes ManagedClusterProperties.IngressProfile, or where the Properties/IngressProfile property layout changed so the reflected getter returns null.","commonSituations":"Upgrading the Azure.Provisioning.ContainerService NuGet package (currently 1.0.0-beta.6) to a newer beta or GA version; the upstream SDK was regenerated and the internal IngressProfile is now built at emit time rather than at setter time; pinning a different transient version via NuGet resolution.","solutions":["Check the installed Azure.Provisioning.ContainerService version and pin the version known to work (1.0.0-beta.6) in Directory.Packages.props","Inspect the new SDK: if ManagedClusterIngressProfile is now public, replace the reflection injector with the standard public-subclass pattern and delete AksPreviewIngressProfileInjector (tracked in aspire issue 17060)","If the type is still internal, find the new lazy-init trigger property (e.g. a different ingress sub-property) and assign that before calling GetIngressProfileInstance","Follow/escalate upstream azure-sdk-for-net issue 59225 for the public API fix"],"exampleFix":"// before (reflection bootstrap)\naks.IngressWebAppRouting = new ManagedClusterIngressProfileWebAppRouting();\nvar ingressProfile = GetIngressProfileInstance(aks);\n// after (once ManagedClusterIngressProfile is public)\naks.IngressProfile.GatewayAPI.Installation = ...\n// i.e. delete AksPreviewIngressProfileInjector and use the public typed surface","handlingStrategy":"try-catch","validationCode":"var propsProp = typeof(ContainerServiceManagedCluster).GetProperty(\"Properties\", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);\nvar ipProp = propsProp?.GetValue(aks) is { } p ? p.GetType().GetProperty(\"IngressProfile\", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) : null;\nbool surfaceIntact = ipProp is not null;","typeGuard":null,"tryCatchPattern":"try\n{\n    AksPreviewIngressProfileInjector.Inject(aks, gatewayApi: true, applicationLoadBalancer: false);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"IngressProfile\"))\n{\n    // Azure.Provisioning surface changed; fall back to non-preview configuration or pin the SDK version.\n}","preventionTips":["Pin Azure.Provisioning.ContainerService to a tested version in Directory.Packages.props","Run publish-mode Bicep generation tests whenever upgrading Azure.Provisioning.* packages","Track aspire issue 17060 and azure-sdk-for-net issue 59225 for the public API replacement"],"tags":["azure","aks","reflection","provisioning"],"backgroundTag":"internal-invariant-violation","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"}