{"record":{"id":"f1b15434975e81da","repo":"microsoft/aspire","slug":"subnet","errorCode":null,"errorMessage":"subnet","messagePattern":"subnet","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sql/AdminDeploymentScriptSubnetAnnotation.cs","lineNumber":19,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\nusing System.Diagnostics.CodeAnalysis;\nusing Aspire.Hosting.ApplicationModel;\nusing Aspire.Hosting.Azure;\n\nnamespace Aspire.Hosting;\n\n/// <summary>\n/// Annotation that stores the ACI subnet reference for deployment script configuration.\n/// </summary>\n[Experimental(\"ASPIREAZURE003\")]\ninternal sealed class AdminDeploymentScriptSubnetAnnotation(AzureSubnetResource subnet) : IResourceAnnotation\n{\n    /// <summary>\n    /// Gets the ACI subnet resource used for deployment scripts.\n    /// </summary>\n    public AzureSubnetResource Subnet { get; } = subnet ?? throw new ArgumentNullException(nameof(subnet));\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sql/AdminDeploymentScriptSubnetAnnotation.cs#L1-L21","documentation":"AdminDeploymentScriptSubnetAnnotation throws ArgumentNullException when the provided AzureSubnetResource is null. The annotation records the ACI subnet used for Azure SQL admin deployment scripts and requires a valid subnet resource.","triggerScenarios":"Constructing AdminDeploymentScriptSubnetAnnotation with a null subnet, e.g. when a lookup for the subnet resource failed or the WithAdminDeploymentScript call chain passed an unresolved resource.","commonSituations":"Custom infrastructure code attaching the annotation manually where the subnet was created conditionally and the variable is null; broken builder chains that did not create the subnet.","solutions":["Create the subnet with AddAzureSubnet (or equivalent) and pass its resource into the annotation.","Ensure the subnet-creating builder call executed and returned a non-null resource before constructing the annotation.","Use the built-in WithAdminDeploymentScriptStorage flow rather than attaching the annotation manually."],"exampleFix":"// before\nvar annotation = new AdminDeploymentScriptSubnetAnnotation(GetSubnetMaybeNull(\"aci\"));\n\n// after\nvar subnet = builder.AddAzureSubnet(\"aci-subnet\", vnet, \"aci\");\nvar annotation = new AdminDeploymentScriptSubnetAnnotation(subnet.Resource);","handlingStrategy":"validation","validationCode":"if (subnetResource is null) throw new InvalidOperationException(\"Subnet must be created before attaching the deployment script annotation.\");","typeGuard":"if (subnetResource is not null) { new AdminDeploymentScriptSubnetAnnotation(subnetResource); }","tryCatchPattern":null,"preventionTips":["Create the subnet resource before referencing it in annotations.","Rely on built-in WithAdminDeploymentScript* extensions.","Null-check conditional subnet creation results."],"tags":["argument-null","azure-sql","subnet"],"backgroundTag":"null-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}