AzureBicepResourceAnnotation(AzureBicepResource) Constructor

Definition

Used to annotate resources as being potentially deployable by the Aspire.Hosting.Azure.AzureProvisioner.

public AzureBicepResourceAnnotation (Aspire.Hosting.Azure.AzureBicepResource resource);
new Aspire.Hosting.Azure.AzureBicepResourceAnnotation : Aspire.Hosting.Azure.AzureBicepResource -> Aspire.Hosting.Azure.AzureBicepResourceAnnotation
Public Sub New (resource As AzureBicepResource)

Parameters

resource
AzureBicepResource

The AzureBicepResource which should be used by the Aspire.Hosting.Azure.AzureProvisioner.

Remarks

The Aspire.Hosting.Azure.AzureProvisioner is only capable of deploying resources that implement IAzureResource and only has built-in deployment logic for resources that derive from AzureBicepResource. This annotation that can be added to any IResource will be detected by the Aspire.Hosting.Azure.AzureProvisioner and used to provision an Azure resource for an Aspire resource type that does not itself derive from AzureBicepResource.

For example, the following code adds a https://video2.skills-academy.com/dotnet/api/aspire.hosting.applicationmodel.sqlserverserverresource resource to the application model. This type does not derive from AzureBicepResource but can be annotated with AzureBicepResourceAnnotation by using the AzureSqlExtensions.AsAzureSqlDatabase() extension method.

var builder = DistributedApplication.CreateBuilder();
builder.AddAzureProvisioning();
var sql = builder.AddSqlServerServer("sql"); // This resource would not be deployable via Azure Provisioner.
sql.AsAzureSqlDatabase(); // ... but it now is because this adds the AzureBicepResourceAnnotation annotation.

Applies to