Create a local Functions project
Create a local Functions project directory which equivalent to a function app in Azure
A Functions project directory contains the files host.json and local.settings.json, along with subfolders that contain the code for individual functions. This directory is the equivalent of a function app in Azure.
Version 3.x/2.x requires you to select a default language for your project when it is initialized. In version 3.x/2.x, all functions added use default language templates. In version 1.x, you specify the language each time you create a function.
Prerequisites
- A Microsoft Azure account.
Use this link to create free one.
Or else use this link to create one.
- Install either the Azure CLI or Azure PowerShell for authenticating with your Azure account to be able to publish to Azure from Azure Functions Core Tools.
Follow this article for the same.
- Install the Azure Functions Core Tools.
Follow this article for the same.
How to create a project?
In the terminal window or from a command prompt, run the following command to create the project and local Git repository:
func init MyFunctionProj
Note: Java uses a Maven archetype to create the local Functions project, along with your first HTTP triggered function. Use the following command to create your Java project:
mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype
. For an example using the Maven archetype, see the Command line quickstart.
When you provide a project name, a new folder with that name is created and initialized. Otherwise, the current folder is initialized.
In version 3.x/2.x, when you run the command you must choose a runtime for your project.
Use the up/down arrow keys to choose a language, then press Enter.
Note: If you plan to develop JavaScript or TypeScript functions, choose node, and then select the language. TypeScript has some additional requirements.
Here we are using python
. Use the down arrow keys to choose the language python.
Then press Enter
.
The output looks like the following example for a Python project:
func init
supports the following options, which are version 3.x/2.x-only, unless otherwise noted:
Note: By default, version 2.x and later versions of the Core Tools create function app projects for the .NET runtime as C# class projects (.csproj). These C# projects, which can be used with Visual Studio or Visual Studio Code, are compiled during testing and when publishing to Azure. If you instead want to create and work with the same C# script (.csx) files created in version 1.x and in the portal, you must include the
--csx
parameter when you create and deploy functions.
Further Reading:
To learn more about the Functions folder structure, see the Azure Functions developers guide.