Aspirerelease/17.0

Compiler error ASPIREAZUREFUNCTIONS001

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Version introduced: 17.0

Directory-based Azure Functions app APIs are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic is reported as an error by default when using the experimental directory-based Azure Functions app APIs in the Aspire.Hosting.Azure.Functions package. These APIs let you model a TypeScript or JavaScript Azure Functions app — one that has no .NET project file — as a resource in your AppHost. The following APIs are affected:

  • AddAzureFunctionsApp extension method on IDistributedApplicationBuilder
  • WithHostStorage extension method on IResourceBuilder<AzureFunctionsAppResource>
  • WithReference extension method on IResourceBuilder<AzureFunctionsAppResource>
  • AzureFunctionsAppResource class
  • AzureFunctionsLanguage enum

These APIs are pending API review and may change shape, or be removed, before becoming generally available (GA). The existing .NET project APIs, such as AddAzureFunctionsProject, are unaffected and do not require this suppression.

The following code generates ASPIREAZUREFUNCTIONS001:

AppHost.cs
using Aspire.Hosting.Azure;
var builder = DistributedApplication.CreateBuilder(args);
var storage = builder.AddAzureStorage("storage").RunAsEmulator();
var blob = storage.AddBlobs("blob");
builder.AddAzureFunctionsApp("functions", "../functions", AzureFunctionsLanguage.TypeScript)
.WithReference(blob);
builder.Build().Run();

Suppress the diagnostic with either of the following methods:

  • Add a #pragma warning disable directive in the source file where the API is used:

    AppHost.cs
    #pragma warning disable ASPIREAZUREFUNCTIONS001
    builder.AddAzureFunctionsApp("functions", "../functions", AzureFunctionsLanguage.TypeScript);
    #pragma warning restore ASPIREAZUREFUNCTIONS001
  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIREAZUREFUNCTIONS001</NoWarn>
    </PropertyGroup>

TypeScript and Go AppHosts This C# compiler diagnostic does not apply to addAzureFunctionsApp calls in TypeScript or AddAzureFunctionsApp calls in Go.