Azure Functions Core Tools

The Azure Functions Core Tools are a set of command-line tools that enable you to develop, test, and deploy Azure Functions locally.

💡 Tip: Ensure you have Node.js (LTS version recommended) installed before installing the Core Tools.

Installation

You can install the Core Tools globally using npm:

npm install -g azure-functions-core-tools@3 --unsafe-perm true

For other installation methods, please refer to the official Microsoft documentation.

Key Commands

Initializing a Project

To create a new Functions project, navigate to your desired directory in the terminal and run:

func init MyFunctionProject --worker-runtime node

Replace MyFunctionProject with your project name and node with your preferred runtime (e.g., dotnet, python, powershell, java, custom).

Creating a New Function

After initializing a project, you can add new functions:

cd MyFunctionProject
func new --template "HTTP trigger" --name MyHttpTrigger

This command creates a new HTTP trigger function named MyHttpTrigger.

Running Locally

To start your Functions host locally:

func start

This will build your functions and make them available at a local URL, typically http://localhost:7071.

Common Scenarios

HTTP Triggers

HTTP-triggered functions are invoked by HTTP requests. The Core Tools make it easy to test these locally.

To test an HTTP trigger, you can use curl or your browser:

curl http://localhost:7071/api/MyHttpTrigger?name=World

Timer Triggers

Timer triggers execute functions on a schedule. You can configure the schedule in the function.json file.

Configuration

The primary configuration file for a function is function.json, located within the function's folder. For project-level settings, you might use local.settings.json.

local.settings.json

This file is used to store application settings, connection strings, and environment variables for local development. It's not deployed to Azure.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}

Deploying Functions

Once you're satisfied with your local development, you can deploy your functions to Azure using the func azure functionapp publish command.

func azure functionapp publish 

Replace <YourFunctionAppName> with the name of your Azure Function App.

Advanced Usage