/FunctionsLibraryAndFunproj

Example of a .funproj along with a Web App project for Azure Functions

Primary LanguageC#

FunctionsClassLibrary

Example of a .funproj along with a Web App project for Azure Functions

Use the web project for building and deploying, and the Functions project for running locally with debugging.

Idea courtesy of @SimonLuckenuik.

Project setup steps

Here are steps on how to produce the project layout in this sample:

  1. Create an ASP.NET Web Application project. Copy any existing Functions code by downloading from Kudu and convert from .csx to .cs files.

  2. (Optional) Copy existing App Settings from a Function App using the Azure Functions CLI:

    func azure login
    func azure functionapp list
    func azure fetch-app-settings <name>
    
  3. Add a new Function Project to the solution. This will create a new folder for the Function Project.

  4. Remove the new Function Project from the solution and navigate to it in Windows explorer.

  5. Copy the files projectname.funproj and host.json to your Web App project folder.

  6. Add the function project to your Visual Studio solution.

  7. Add a manual project dependency between the two projects: right-click on the Function project and navigate to Build Dependencies -> Project Dependencies....

Running and publishing

The Functions project automatically includes files from the project directory and since it is the same directory as the Web Project, it will include any binaries.

Use the Functions project to run and publish, and the Web project to do the actual build.