# AzureFunctionsProjectResourceExtensions Methods

- Package: [Aspire.Hosting.Azure.Functions](/reference/api/csharp/aspire.hosting.azure.functions.md)
- Type: [AzureFunctionsProjectResourceExtensions](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresourceextensions.md)
- Kind: `Methods`
- Members: `4`

Extension methods for [AzureFunctionsProjectResource](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresource.md).

## AddAzureFunctionsProject(IDistributedApplicationBuilder, string)

- Name: `AddAzureFunctionsProject(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFunctionsProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs#L67-L71)

Adds an Azure Functions project to the distributed application.

```csharp
public static class AzureFunctionsProjectResourceExtensions
{
    public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject<TProject>(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `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.

## Returns

`IResourceBuilder<AzureFunctionsProjectResource>` -- An `ApplicationModel.IResourceBuilder`1` for the added Azure Functions project resource.

## Remarks

This overload is not available in polyglot app hosts. Use [AzureFunctionsProjectResourceExtensions.AddAzureFunctionsProject(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresourceextensions/methods.md#addazurefunctionsproject-idistributedapplicationbuilder-string) 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:

- `StorageBuiltInRole.StorageBlobDataContributor`
- `StorageBuiltInRole.StorageTableDataContributor`
- `StorageBuiltInRole.StorageQueueDataContributor`
- `StorageBuiltInRole.StorageAccountContributor`

For more information, see [Azure Functions host storage](https://learn.microsoft.com/azure/azure-functions/dotnet-aspire-integration#azure-functions-host-storage).

Use [AzureFunctionsProjectResourceExtensions.WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>)](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresourceextensions/methods.md#withhoststorage-iresourcebuilder-azurefunctionsprojectresource-iresourcebuilder-azurestorageresource) to specify a custom Azure Storage resource as the host storage instead of the implicit default storage account.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddAzureFunctionsProject(IDistributedApplicationBuilder, string, string)

- Name: `AddAzureFunctionsProject(IDistributedApplicationBuilder, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFunctionsProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs#L124-L131)

Adds an Azure Functions project to the distributed application.

```csharp
public static class AzureFunctionsProjectResourceExtensions
{
    public static IResourceBuilder<AzureFunctionsProjectResource> AddAzureFunctionsProject(
        this IDistributedApplicationBuilder builder,
        string name,
        string projectPath)
    {
        // ...
    }
}
```

## Parameters

- `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.

## Returns

`IResourceBuilder<AzureFunctionsProjectResource>` -- An `ApplicationModel.IResourceBuilder`1` for the added Azure Functions project resource.

## Remarks

This overload of the [AzureFunctionsProjectResourceExtensions.AddAzureFunctionsProject(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresourceextensions/methods.md#addazurefunctionsproject-idistributedapplicationbuilder-string) 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](https://learn.microsoft.com/azure/azure-functions/dotnet-aspire-integration#azure-functions-host-storage).

Use [AzureFunctionsProjectResourceExtensions.WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>)](/reference/api/csharp/aspire.hosting.azure.functions/azurefunctionsprojectresourceextensions/methods.md#withhoststorage-iresourcebuilder-azurefunctionsprojectresource-iresourcebuilder-azurestorageresource) 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.

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddAzureFunctionsProject("funcapp", @"..\MyFunctions\MyFunctions.csproj");

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>)

- Name: `WithHostStorage(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<AzureStorageResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFunctionsProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs#L324-L328)

Configures the Azure Functions project resource to use the specified Azure Storage resource as its host storage.

```csharp
public static class AzureFunctionsProjectResourceExtensions
{
    public static IResourceBuilder<AzureFunctionsProjectResource> WithHostStorage(
        this IResourceBuilder<AzureFunctionsProjectResource> builder,
        IResourceBuilder<AzureStorageResource> storage)
    {
        // ...
    }
}
```

## Parameters

- `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.

## Returns

`IResourceBuilder<AzureFunctionsProjectResource>` -- The resource builder for the Azure Functions project resource, configured with the specified host storage.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?)

- Name: `WithReference(IResourceBuilder<AzureFunctionsProjectResource>, IResourceBuilder<TSource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureFunctionsProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs#L344-L353)

Injects Azure Functions specific connection information into the environment variables of the Azure Functions project resource.

```csharp
public static class AzureFunctionsProjectResourceExtensions
{
    public static IResourceBuilder<AzureFunctionsProjectResource> WithReference<TSource>(
        this IResourceBuilder<AzureFunctionsProjectResource> destination,
        IResourceBuilder<TSource> source,
        string? connectionName = null)
    {
        // ...
    }
}
```

## Parameters

- `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.

## Remarks

This method is not available in polyglot app hosts. Use the standard `withReference` method from the base resource builder instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
