Compiler Error ASPIREAZURE004
此内容尚不支持你的语言。
‘Aspire.Hosting.Azure.AzureResourceInfrastructure.BicepExtensions’ is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
The AzureResourceInfrastructure.BicepExtensions property declares Bicep extensions for the module that Aspire generates for an Azure resource. Each entry maps a namespace alias to an extension reference, such as br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:1.0.0. Aspire writes the references inline, so the generated module doesn’t depend on a bicepconfig.json file.
This property is experimental and might change in future releases. The C# compiler reports ASPIREAZURE004 when your AppHost uses it.
Example
Section titled “Example”The following code generates ASPIREAZURE004:
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureInfrastructure("graph", infrastructure =>{ // Using BicepExtensions generates ASPIREAZURE004 infrastructure.BicepExtensions["microsoftGraphV1"] = "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:1.0.0";});
builder.Build().Run();TypeScript AppHosts can’t use this property, so they don’t report this diagnostic.
To correct this error
Section titled “To correct this error”Suppress the error with one of the following methods:
-
Set the severity of the rule in the .editorconfig file.
.editorconfig [*.{cs,vb}]dotnet_diagnostic.ASPIREAZURE004.severity = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIREAZURE004</NoWarn></PropertyGroup> -
Add the following property directive to a file-based AppHost:
AppHost.cs #:property NoWarn=ASPIREAZURE004 -
Suppress in code with the
#pragma warning disable ASPIREAZURE004directive:Suppressing the error #pragma warning disable ASPIREAZURE004infrastructure.BicepExtensions["microsoftGraphV1"] ="br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:1.0.0";#pragma warning restore ASPIREAZURE004