Skip to content
DocsTry Aspire
DocsTry

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)
{
// ...
}
}
infraAzureResourceInfrastructureThe AzureResourceInfrastructure to add the existing resource into.
ProvisionableResourceA 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)
{
// ...
}
}
roleAssignmentContextIAddRoleAssignmentsContextThe 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>)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)
{
// ...
}
}
infrastructureAzureResourceInfrastructureThe AzureResourceInfrastructure that will contain the Primitives.ProvisionableResource.
createExistingFunc<string, BicepValue<string>, T>A callback to create the existing resource.
createNewFunc<AzureResourceInfrastructure, T>A callback to create the new resource.
TThe provisioned resource.
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)
{
// ...
}
}
directorystring?optionalThe directory where the bicep file will be written to (if it's a temporary file)
deleteTemporaryFileOnDisposebooloptionalA boolean that determines if the file should be deleted on disposal of the BicepTemplateFile.
BicepTemplateFileA BicepTemplateFile that represents the bicep file.
InvalidOperationException
GetBicepTemplateStringSection titled GetBicepTemplateStringoverridestring
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)
{
// ...
}
}
aspireResourceIAzureResourceThe Aspire resource that may have an ExistingAzureResourceAnnotation.
infraAzureResourceInfrastructureThe infrastructure used for converting parameters into provisioning expressions.
provisionableResourceProvisionableResourceThe Primitives.ProvisionableResource resource to configure.
booltrue 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.