AzureProvisioningResource Methods
ClassMethods6 members
An Aspire resource that supports use of Azure Provisioning APIs to create Azure resources.
AddAsExistingResource(AzureResourceInfrastructure) Section titled AddAsExistingResource(AzureResourceInfrastructure)virtualProvisionableResource Adds a new
Primitives.ProvisionableResource into infra. The new resource represents a reference to the current AzureProvisioningResource via https://learn.microsoft.com/azure/azure-resource-manager/bicep/existing-resource. public class AzureProvisioningResource{ public virtual ProvisionableResource AddAsExistingResource( AzureResourceInfrastructure infra) { // ... }}Parameters
infraAzureAzureResourceInfrastructure to add the existing resource into.Returns
ProvisionableResource A new Primitives.ProvisionableResource , typically using the FromExisting method on the derived Primitives.ProvisionableResource class.AddRoleAssignments(IAddRoleAssignmentsContext) Section titled AddRoleAssignments(IAddRoleAssignmentsContext)virtual Adds role assignments to this Azure resource.
public class AzureProvisioningResource{ public virtual void AddRoleAssignments( IAddRoleAssignmentsContext roleAssignmentContext) { // ... }}Parameters
roleAssignmentContext ICreateExistingOrNewProvisionableResource(AzureResourceInfrastructure, Func<string, BicepValue<string>, T>, Func<AzureResourceInfrastructure, T>) Section titled CreateExistingOrNewProvisionableResource(AzureResourceInfrastructure, Func<string, BicepValue<string>, T>, Func<AzureResourceInfrastructure, T>)staticT Encapsulates the logic for creating an existing or new
Primitives.ProvisionableResource based on whether or not the ExistingAzureResourceAnnotation exists on the resource. public class AzureProvisioningResource{ public static T CreateExistingOrNewProvisionableResource<T>( AzureResourceInfrastructure infrastructure, Func<string, BicepValue<string>, T> createExisting, Func<AzureResourceInfrastructure, T> createNew) { // ... }}Parameters
infrastructureAzureAzureResourceInfrastructure that will contain the Primitives.ProvisionableResource .createExisting Func<string, BicepValue<string>, T> A callback to create the existing resource.createNew Func<AzureResourceInfrastructure, T> A callback to create the new resource.Returns
TThe provisioned resource.GetBicepTemplateFile(string?, bool) Section titled GetBicepTemplateFile(string?, bool)overrideBicep Gets the path to the bicep file. If the template is a string or embedded resource, it will be written to a temporary file.
public class AzureProvisioningResource{ public override BicepTemplateFile GetBicepTemplateFile( string? directory = null, bool deleteTemporaryFileOnDispose = true) { // ... }}Parameters
directorystring?optionalThe directory where the bicep file will be written to (if it's a temporary file)deleteTemporaryFileOnDispose booloptionalA boolean that determines if the file should be deleted on disposal of the BicepTemplateFile .Returns
BicepTemplateFile A BicepTemplateFile that represents the bicep file.Exceptions
InvalidOperationException Get the bicep template as a string. Does not write to disk.
public class AzureProvisioningResource{ public override string GetBicepTemplateString() { // ... }}TryApplyExistingResourceAnnotation(IAzureResource, AzureResourceInfrastructure, ProvisionableResource) Section titled TryApplyExistingResourceAnnotation(IAzureResource, AzureResourceInfrastructure, ProvisionableResource)staticbool Attempts to apply the name and (optionally) the resource group scope for the
Primitives.ProvisionableResource from an ExistingAzureResourceAnnotation attached to aspireResource . public class AzureProvisioningResource{ public static bool TryApplyExistingResourceAnnotation( IAzureResource aspireResource, AzureResourceInfrastructure infra, ProvisionableResource provisionableResource) { // ... }}Parameters
aspireResource IExistingAzureResourceAnnotation .infraAzureprovisionableResource ProvisionableResource The Primitives.ProvisionableResource resource to configure.Returns
booltrue if an ExistingAzureResourceAnnotation was present and applied; otherwise false.Remarks
When the annotation includes a resource group, a synthetic
scope property is added to the resource's provisionable properties to correctly scope the existing resource in the generated Bicep. The caller is responsible for setting a generated name when the method returns false.