Aspire

Compiler Error ASPIREAZURE003

Version introduced: 13.2

Azure Virtual Network types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

The Aspire Azure hosting integration now ships with support for Azure Virtual Networks. If you’re using any of the Aspire.Hosting.Azure.Network APIs such as AddAzureVirtualNetworkaddAzureVirtualNetworkAddAzureVirtualNetwork, you might see a compiler error/warning indicating that the API is experimental. This behavior is expected, as the API is still in preview and the shape of this API is expected to change in the future.

Other Azure private networking APIs report the same diagnostic. These include WithAzureFrontDoorPrivateLink, which connects an Azure Front Door to an Azure Container Apps or Azure App Service environment over Private Link. For more information, see Private Link origins.

The following code generates ASPIREAZURE003:

AppHost.cs
var vnet = builder.AddAzureVirtualNetwork("vnet");
var subnet = vnet.AddSubnet("pe-subnet", "10.0.1.0/24");

The following code also generates ASPIREAZURE003:

AppHost.cs
var environment = builder.AddAzureContainerAppEnvironment("env");
var frontDoor = builder.AddAzureFrontDoor("frontdoor");
environment.WithAzureFrontDoorPrivateLink(frontDoor);

Suppress the error with either of the following methods:

  • Set the severity of the rule in the .editorconfig file.

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIREAZURE003.severity = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIREAZURE003</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIREAZURE003 directive.