Skip to content
Docs Try Aspire

AzureProvisioningResource Methods

Class Methods 6 members
An Aspire resource that supports use of Azure Provisioning APIs to create Azure resources.
AddAsExistingResource(AzureResourceInfrastructure) Section titled AddAsExistingResource(AzureResourceInfrastructure) virtual ProvisionableResource
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)
{
// ...
}
}
infra AzureResourceInfrastructure The AzureResourceInfrastructure to add the existing resource into.
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)
{
// ...
}
}
roleAssignmentContext IAddRoleAssignmentsContext The context containing information about the role assignments and what principal to use.
CreateExistingOrNewProvisionableResource(AzureResourceInfrastructure, Func<string, BicepValue<string>, T>, Func<AzureResourceInfrastructure, T>) Section titled CreateExistingOrNewProvisionableResource(AzureResourceInfrastructure, Func<string, BicepValue<string>, T>, Func<AzureResourceInfrastructure, T>) static T
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)
{
// ...
}
}
infrastructure AzureResourceInfrastructure The AzureResourceInfrastructure 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.
T The provisioned resource.
GetBicepTemplateFile(string?, bool) Section titled GetBicepTemplateFile(string?, bool) override BicepTemplateFile
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)
{
// ...
}
}
directory string? optional The directory where the bicep file will be written to (if it's a temporary file)
deleteTemporaryFileOnDispose bool optional A boolean that determines if the file should be deleted on disposal of the BicepTemplateFile.
BicepTemplateFile A BicepTemplateFile that represents the bicep file.
InvalidOperationException
GetBicepTemplateString Section titled GetBicepTemplateString override string
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) static bool
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)
{
// ...
}
}
aspireResource IAzureResource The Aspire resource that may have an ExistingAzureResourceAnnotation.
infra AzureResourceInfrastructure The infrastructure used for converting parameters into provisioning expressions.
provisionableResource ProvisionableResource The Primitives.ProvisionableResource resource to configure.
bool true if an ExistingAzureResourceAnnotation was present and applied; otherwise false.
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.