Skip to content
Docs Try Aspire

AzureBicepResourceAnnotation Constructors

Class Constructors 1 member
Used to annotate resources as being potentially deployable by the Azure.AzureProvisioner.
Constructor(AzureBicepResource) Section titled Constructor(AzureBicepResource)
Used to annotate resources as being potentially deployable by the Azure.AzureProvisioner.
public class AzureBicepResourceAnnotation
{
public AzureBicepResourceAnnotation(
AzureBicepResource resource)
{
// ...
}
}
resource AzureBicepResource The AzureBicepResource which should be used by the Azure.AzureProvisioner.

The 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 ApplicationModel.IResource will be detected by the 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://learn.microsoft.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.