{"record":{"id":"b2ed7881883c087f","repo":"microsoft/aspire","slug":"containerservicemanagedcluster-properties-not-found-via","errorCode":null,"errorMessage":"ContainerServiceManagedCluster.Properties not found via reflection. The Azure.Provisioning surface may have changed; review AksPreviewIngressProfileInjector.","messagePattern":"ContainerServiceManagedCluster\\.Properties not found via reflection\\. The Azure\\.Provisioning surface may have changed; review AksPreviewIngressProfileInjector\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs","lineNumber":165,"sourceCode":"                    new[] { \"applicationLoadBalancer\", \"enabled\" },\n                    /* isOutput */ false,\n                    /* isRequired */ false,\n                    /* isSecure */ false,\n                    /* defaultValue */ null,\n                    /* format */ null,\n                ])!;\n            enabled.Assign(true);\n        }\n    }\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}","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kubernetes/AksPreviewIngressProfileInjector.cs#L147-L183","documentation":"GetIngressProfileInstance reflects over ContainerServiceManagedCluster to fetch its (internal) Properties property, which owns the ingress profile. This error is thrown when GetProperty(\"Properties\", Public|NonPublic|Instance) returns null — the Azure.Provisioning.ContainerService type no longer has a Properties member, so the injector cannot reach the internal ManagedClusterProperties object that owns IngressProfile.","triggerScenarios":"A newer Azure.Provisioning.ContainerService package renamed or removed ManagedClusterProperties/Properties on ContainerServiceManagedCluster, and the app model enables AKS preview ingress features (gatewayAPI or applicationLoadBalancer) so AksPreviewIngressProfileInjector.Inject runs during publish/Bicep generation.","commonSituations":"Upgrading Azure.Provisioning.ContainerService beyond 1.0.0-beta.6 via central package management; a transitive dependency upgrading the package; using an Aspire build against a mismatched azure-sdk-for-net beta where the cluster model was reshaped (e.g. properties flattened into top-level properties).","solutions":["Pin Azure.Provisioning.ContainerService to the version Aspire was validated against (1.0.0-beta.6) in Directory.Packages.props","Inspect the installed ContainerServiceManagedCluster type for the new location of the properties complex object and update the GetIngressProfileInstance reflection lookup accordingly","If IngressProfile/GatewayApi/ApplicationLoadBalancer became public in the new version, replace the reflection injector with the typed public-subclass pattern (see ContainerAppEnvironmentDotnetComponentResource for the pattern)","Restore clean packages (nuget locals all -clear) to rule out a stale/mixed assembly set","Track microsoft/aspire#17060 and Azure/azure-sdk-for-net#59225 for the upstream fix that deletes this reflection code"],"exampleFix":"// before\nvar clusterPropsProp = typeof(ContainerServiceManagedCluster).GetProperty(\"Properties\", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)\n    ?? throw new InvalidOperationException(\"...Properties not found...\");\n// after (if upstream flattened properties)\nvar clusterProps = aks; // properties now live directly on the construct\nvar ipProp = clusterProps.GetType().GetProperty(\"IngressProfile\", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)\n    ?? throw new InvalidOperationException(\"...IngressProfile not found...\");","handlingStrategy":"fallback","validationCode":"var propsProp = typeof(ContainerServiceManagedCluster).GetProperty(\"Properties\",\n    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);\nif (propsProp is null)\n{\n    throw new InvalidOperationException(\"ContainerServiceManagedCluster.Properties is unavailable in the bound Azure.Provisioning.ContainerService version; preview ingress injection is not supported.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    AksPreviewIngressProfileInjector.Inject(aks, gatewayApi, applicationLoadBalancer);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Properties not found\"))\n{\n    throw new InvalidOperationException(\"AKS preview ingress features require a compatible Azure.Provisioning.ContainerService version (1.0.0-beta.6).\", ex);\n}","preventionTips":["Keep Azure.Provisioning.ContainerService at the version Aspire was built against","Before upgrading, inspect the ContainerServiceManagedCluster type for reshaped Properties members","Gate preview ingress features behind a config flag so an incompatible package version disables the feature instead of failing publish","Add a smoke test that publishes an AKS app model with gateway API enabled on every package bump"],"tags":["reflection","azure","aks","azure-provisioning","version-incompatibility"],"backgroundTag":"class-not-found","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"}