Skip to content
Docs Try Aspire

AzureFunctionsProjectResourceExtensions Methods

Class Methods 4 members
Extension methods for AzureFunctionsProjectResource.
AddAzureFunctionsProject(IDistributedApplicationBuilder, string) Section titled AddAzureFunctionsProject(IDistributedApplicationBuilder, string) extension IResourceBuilder<AzureFunctionsProjectResource>
Adds an Azure Functions project to the distributed application.
public static class AzureFunctionsProjectResourceExtensions
{
public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject<TProject>(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to which the Azure Functions project will be added.
name string The name to be associated with the Azure Functions project. This name will be used for service discovery when referenced in a dependency.
IResourceBuilder<AzureFunctionsProjectResource> An ApplicationModel.IResourceBuilder`1 for the added Azure Functions project resource.

When Functions projects are deployed to Azure Container Apps, they are provisioned with the container app kind property set to functionapp. This enables KEDA auto-scaler rules to be automatically configured based on the Azure Functions triggers defined in the project.

By default, an implicit Azure Storage account is provisioned to be used as host storage for the Functions runtime. This storage account is required by the Azure Functions runtime for operations such as managing triggers, logging function executions, and coordinating instances. The implicit storage account is assigned the following roles:

  • StorageBuiltInRole.StorageBlobDataContributor
  • StorageBuiltInRole.StorageTableDataContributor
  • StorageBuiltInRole.StorageQueueDataContributor
  • StorageBuiltInRole.StorageAccountContributor
For more information, see Azure Functions host storage.

Use AzureFunctionsProjectResourceExtensions.WithHostStorage to specify a custom Azure Storage resource as the host storage instead of the implicit default storage account.

AddAzureFunctionsProject(IDistributedApplicationBuilder, string, string) Section titled AddAzureFunctionsProject(IDistributedApplicationBuilder, string, string) extension IResourceBuilder<AzureFunctionsProjectResource>
Adds an Azure Functions project to the distributed application.
public static class AzureFunctionsProjectResourceExtensions
{
public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject(
this IDistributedApplicationBuilder builder,
string name,
string projectPath)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to which the Azure Functions project will be added.
name string The name to be associated with the Azure Functions project. This name will be used for service discovery when referenced in a dependency.
projectPath string The path to the Azure Functions project file.
IResourceBuilder<AzureFunctionsProjectResource> An ApplicationModel.IResourceBuilder`1 for the added Azure Functions project resource.

This overload of the AzureFunctionsProjectResourceExtensions.AddAzureFunctionsProject method adds an Azure Functions project to the application model using a path to the project file. This allows for projects to be referenced that may not be part of the same solution. If the project path is not an absolute path then it will be computed relative to the app host directory.

When Functions projects are deployed to Azure Container Apps, they are provisioned with the container app kind property set to functionapp. This enables KEDA auto-scaler rules to be automatically configured based on the Azure Functions triggers defined in the project.

By default, an implicit Azure Storage account is provisioned to be used as host storage for the Functions runtime. This storage account is required by the Azure Functions runtime for operations such as managing triggers, logging function executions, and coordinating instances. The implicit storage account is assigned the following roles:

  • StorageBuiltInRole.StorageBlobDataContributor
  • StorageBuiltInRole.StorageTableDataContributor
  • StorageBuiltInRole.StorageQueueDataContributor
  • StorageBuiltInRole.StorageAccountContributor
For more information, see Azure Functions host storage.

Use AzureFunctionsProjectResourceExtensions.WithHostStorage to specify a custom Azure Storage resource as the host storage instead of the implicit default storage account.

Add an Azure Functions project to the app model via a project path.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureFunctionsProject(
"funcapp",
@"..\MyFunctions\MyFunctions.csproj");
builder.Build().Run();
WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>) Section titled WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>) extension IResourceBuilder<AzureFunctionsProjectResource>
Configures the Azure Functions project resource to use the specified Azure Storage resource as its host storage.
public static class AzureFunctionsProjectResourceExtensions
{
public static IResourceBuilder<AzureFunctionsProjectResource> WithHostStorage(
this IResourceBuilder<AzureFunctionsProjectResource> builder,
IResourceBuilder<AzureStorageResource> storage)
{
// ...
}
}
builder IResourceBuilder<AzureFunctionsProjectResource> The resource builder for the Azure Functions project resource.
storage IResourceBuilder<AzureStorageResource> The resource builder for the Azure Storage resource to be used as host storage.
IResourceBuilder<AzureFunctionsProjectResource> The resource builder for the Azure Functions project resource, configured with the specified host storage.
WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?) Section titled WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?) extension IResourceBuilder<AzureFunctionsProjectResource>
Injects Azure Functions specific connection information into the environment variables of the Azure Functions project resource.
public static class AzureFunctionsProjectResourceExtensions
{
public static IResourceBuilder<AzureFunctionsProjectResource> WithReference<TSource>(
this IResourceBuilder<AzureFunctionsProjectResource> destination,
IResourceBuilder<TSource> source,
string? connectionName = null)
{
// ...
}
}
destination IResourceBuilder<AzureFunctionsProjectResource> The resource where connection information will be injected.
source IResourceBuilder<TSource> The resource from which to extract the connection string.
connectionName string? optional An override of the source resource's name for the connection name. The resulting connection name will be connectionName if this is not null.