AzureFunctionsProjectResourceExtensions Methods
AzureFunctionsProjectResource . AddAzureFunctionsApp(IDistributedApplicationBuilder, string, string, AzureFunctionsLanguage) Section titled AddAzureFunctionsApp(IDistributedApplicationBuilder, string, string, AzureFunctionsLanguage)extensionIResourceBuilder<AzureFunctionsAppResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsAppResource> AddAzureFunctionsApp( this IDistributedApplicationBuilder builder, string name, string appDirectory, AzureFunctionsLanguage language) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to which the Azure Functions app will be added.namestringThe name to be associated with the Azure Functions app. This name will be used for service discovery when referenced in a dependency.appDirectory stringThe path to the directory containing the Azure Functions app.languageAzureReturns
IResourceBuilder<AzureFunctionsAppResource> An ApplicationModel.IResourceBuilder`1 for the added Azure Functions app resource.Exceptions
ArgumentNullExceptionThrown when builder, name, or appDirectory is null.ArgumentExceptionThrown when name or appDirectory is empty.Remarks
This overload is intended for Azure Functions apps that do not have a .NET project file, such as TypeScript and JavaScript apps that run on the Node language worker. TypeScript apps are launched through npm run start so the standard Core Tools generated prestart script can build the app before the Functions host starts. The start script should resolve Azure Functions Core Tools from the app's local npm dependencies, for example by depending on the azure- package.
By default, an implicit Azure Storage account is provisioned to be used as host storage for the Functions runtime. Use Azure to specify a custom Azure Storage resource as the host storage instead.
#pragma warning disable ASPIREAZUREFUNCTIONS001
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureFunctionsApp( "funcapp", "../functions", AzureFunctionsLanguage.TypeScript);
builder.Build().Run();
#pragma warning restore ASPIREAZUREFUNCTIONS001AddAzureFunctionsProject(IDistributedApplicationBuilder, string) Section titled AddAzureFunctionsProject(IDistributedApplicationBuilder, string)extensionIResourceBuilder<AzureFunctionsProjectResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject<TProject>( this IDistributedApplicationBuilder builder, string name) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to which the Azure Functions project will be added.namestringThe name to be associated with the Azure Functions project. This name will be used for service discovery when referenced in a dependency.Returns
IResourceBuilder<AzureFunctionsProjectResource> An ApplicationModel.IResourceBuilder`1 for the added Azure Functions project resource.Remarks
This overload is not available in polyglot AppHosts. Use Azure with a project path instead.
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:
For more information, see Azure Functions host storage. StorageStorageStorageStorage
Use the With method 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)extensionIResourceBuilder<AzureFunctionsProjectResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject( this IDistributedApplicationBuilder builder, string name, string projectPath) { // ... }}Parameters
builderIDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to which the Azure Functions project will be added.namestringThe name to be associated with the Azure Functions project. This name will be used for service discovery when referenced in a dependency.projectPath stringThe path to the Azure Functions project file.Returns
IResourceBuilder<AzureFunctionsProjectResource> An ApplicationModel.IResourceBuilder`1 for the added Azure Functions project resource.Remarks
This overload of the Azure 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 AppHost 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:
For more information, see Azure Functions host storage. StorageStorageStorageStorage
Use the With method to specify a custom Azure Storage resource as the host storage instead of the implicit default storage account.
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>)extensionIResourceBuilder<AzureFunctionsProjectResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsProjectResource> WithHostStorage( this IResourceBuilder<AzureFunctionsProjectResource> builder, IResourceBuilder<AzureStorageResource> storage) { // ... }}Parameters
builderIResourceBuilder<AzureFunctionsProjectResource> The resource builder for the Azure Functions project resource.storageIResourceBuilder<AzureStorageResource> The resource builder for the Azure Storage resource to be used as host storage.Returns
IResourceBuilder<AzureFunctionsProjectResource> The resource builder for the Azure Functions project resource, configured with the specified host storage.WithHostStorage(IResourceBuilder<AzureFunctionsAppResource>, IResourceBuilder<AzureStorageResource>) Section titled WithHostStorage(IResourceBuilder<AzureFunctionsAppResource>, IResourceBuilder<AzureStorageResource>)extensionIResourceBuilder<AzureFunctionsAppResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsAppResource> WithHostStorage( this IResourceBuilder<AzureFunctionsAppResource> builder, IResourceBuilder<AzureStorageResource> storage) { // ... }}Parameters
builderIResourceBuilder<AzureFunctionsAppResource> The resource builder for the Azure Functions app resource.storageIResourceBuilder<AzureStorageResource> The resource builder for the Azure Storage resource to be used as host storage.Returns
IResourceBuilder<AzureFunctionsAppResource> The resource builder for the Azure Functions app resource, configured with the specified host storage.WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?) Section titled WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?)extensionIResourceBuilder<AzureFunctionsProjectResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsProjectResource> WithReference<TSource>( this IResourceBuilder<AzureFunctionsProjectResource> destination, IResourceBuilder<TSource> source, string? connectionName = null) { // ... }}Parameters
destinationIResourceBuilder<AzureFunctionsProjectResource> The resource where connection information will be injected.sourceIResourceBuilder<TSource> The resource from which to extract the connection string.connectionName string?optionalAn override of the source resource's name for the connection name. The resulting connection name will be connectionName if this is not null.Remarks
withReference method from the base resource builder instead.WithReference(IResourceBuilder<AzureFunctionsAppResource>, IResourceBuilder<TSource>, string?) Section titled WithReference(IResourceBuilder<AzureFunctionsAppResource>, IResourceBuilder<TSource>, string?)extensionIResourceBuilder<AzureFunctionsAppResource> public static class AzureFunctionsProjectResourceExtensions{ public static IResourceBuilder<AzureFunctionsAppResource> WithReference<TSource>( this IResourceBuilder<AzureFunctionsAppResource> destination, IResourceBuilder<TSource> source, string? connectionName = null) { // ... }}Parameters
destinationIResourceBuilder<AzureFunctionsAppResource> The resource where connection information will be injected.sourceIResourceBuilder<TSource> The resource from which to extract the connection string.connectionName string?optionalAn override of the source resource's name for the connection name. The resulting connection name will be connectionName if this is not null.Remarks
withReference method from the base resource builder instead.