microsoft / microsoft/aspire.dev

Using existing Azure Functions project

Open
#195 2 comments 0 reactions 1 assignee View on GitHub

@IEvangelist is already working on this.

Since Jun 2, 2026.

Dominant language
MDX
Stars
193
Forks
87
Avg merge
1d 22h
Merged PRs (30d)
73

Description

Hey team, I'd like to be able to use an existing Azure Functions project with my Aspire deployment to take advantage of Flex Consumption, but I'm getting compile errors when trying to use the **AsExisting() methods. I'm using VS Code with the latest package versions. I've searched the docs for examples of using AsExisting with Functions projects but can't seem to find clear guidance on how to do this (if it's possible).

AppHost.cs

var existingFuncName = builder.AddParameter("existingFuncName", value: "my-funcs");
var existingFuncResourceGroup = builder.AddParameter("existingFuncResourceGroup", value: "my-rg");

var funcs = builder.AddAzureFunctionsProject<Projects.MyProject_Functions>("functions")
    .RunAsExisting(existingFuncName, existingFuncResourceGroup);  // ERROR ON THIS LINE, red squiggles under "RunAsExisting"

Error text

The type 'Aspire.Hosting.Azure.AzureFunctionsProjectResource' cannot be used as type parameter 'T' in the generic type or method 'ExistingAzureResourceExtensions.RunAsExisting<T>(IResourceBuilder<T>, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>?)'. There is no implicit reference conversion from 'Aspire.Hosting.Azure.AzureFunctionsProjectResource' to 'Aspire.Hosting.ApplicationModel.IAzureResource'.[CS0311](https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0311))

AppHost.csproj

<Project Sdk="Aspire.AppHost.Sdk/13.1.0">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <UserSecretsId><REDACTED></UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyProject.ApiService\MyProject.ApiService.csproj" />
    <ProjectReference Include="..\MyProject.Functions\MyProject.Functions.csproj" />
  </ItemGroup>

  <ItemGroup>
      <PackageReference Include="Aspire.Hosting.Azure.Sql" Version="13.1.0" />
      <PackageReference Include="Aspire.Hosting.Azure.Functions" Version="13.1.0" />
      <PackageReference Include="Aspire.Hosting.Azure.Storage" Version="13.1.0" />
      <PackageReference Include="Aspire.Hosting.JavaScript" Version="13.1.0" />
      <PackageReference Include="Aspire.Hosting.OpenAI" Version="13.1.0" />
      <PackageReference Include="Scalar.Aspire" Version="0.7.3" />
    </ItemGroup>

</Project>

User Secrets snippet

{
  "Azure:SubscriptionId": "<my subscription id>",
  "Azure:ResourceGroup": "my-rg",
  "Azure:Location": "eastus2"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.