Skip to content
Docs Try Aspire

AzureBicepResourceAnnotation

Class net8.0
📦 Aspire.Hosting.Azure v13.2.0
Used to annotate resources as being potentially deployable by the Azure.AzureProvisioner.
namespace Aspire.Hosting.Azure;
public class AzureBicepResourceAnnotation
: Aspire.Hosting.ApplicationModel.IResourceAnnotation
{
// ...
}
IResourceAnnotation

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.