Develop Azure Functions on any platform

3 minute read • September 25, 2017

Donna Malayeri
I’m excited to announce that we have ported Azure Functions to .NET Core 2.0! Both the runtime and the Azure Functions Core Tools are now cross-platform. Now, you can debug C# and JavaScript functions on a Mac or Linux using the Core Tools and Visual Studio Code. Both the runtime and the Core Tools are still in preview and we welcome your feedback! As this is a preview release, there are still a number of feature gaps. For more information, see Azure Functions runtime 2.0 known issues.

Running on your local machine

To get the new version of the core tools, pull down the @core tag on npm:
npm i -g azure-functions-core-tools@core
If you’re using Ubuntu, prefix the command above with "sudo." If you have problems with the npm install on Mac, use the following:
sudo npm i -g azure-functions-core-tools@core --unsafe-perm
To learn how to use the tools, see Code and test Azure functions locally.

JavaScript (Node 8.5 or higher)

For the easiest installation, you must be running Node version 8.5 or higher. See instructions below for how to target a lower version. To create a new JavaScript HTTP-triggered function, do the following:
mkdir JavaScriptHttp
cd JavaScriptHttp
func init .
func new --language JavaScript --template HttpTrigger --name HttpTriggerJavaScript
Run the host. This automatically enables debugging with the Node port 5858:
func host start
Open the folder in Visual Studio Code: code . In VSCode, set a breakpoint at the first line of the function, and attach the debugger (via F5 or the debug toolbar). Then, in a browser, navigate to the URL http://localhost:7071/api/HttpTriggerJavaScript?name=Functions%20Everywhere! You’ll then see the breakpoint being hit in VSCode!

JavaScript (Node versions prior to 8)

After installing azure-functions-core-tools, run the following commands:
npm i -g node-pre-gyp
cd %userprofile%/.azurefunctions/bin/workers/node/grpc
node-pre-gyp install
Once these tools are installed, you can use the instructions in the previous section to run and debug JavaScript functions.

C# .NET Standard 2.0 class library

You can now run and debug C# functions on a Mac or Linux. The Microsoft.NET.Sdk.Functions  is the package that identifies a project as Functions project to Visual Studio and generates function.json from attributes during build. Templates for C# class libraries aren’t yet available in the Core Tools, but you can get a sample from GitHub.

Dotnet command line

git clone https://github.com/lindydonna/CSharpHttpCore.git
cd CSharpHttpCore
dotnet build
dotnet publish
cd HttpTriggerCore/bin/Debug/netstandard2.0
func host start 

VS Code debugging

To debug your C# functions, open the folder containing your .csproj in VS Code. Make sure you have installed the C# extension.
  • In the debug toolbar next to the play button, select Add Configuration
  • Select .NET Core as the environment, then .NET: Attach to local .NET Core Console App.
This will generate a launch.json configuration for your project. Then, press F5 and select .NET Core Attach. Select the dotnet process with the command line Azure.Functions.Cli.dll host start. Browse to the URL http://localhost:7071/api/HttpTriggerCSharp?name=CSharpEverywhere!. You’ll then see your breakpoint hit in VSCode.

Visual Studio

First, ensure you have downloaded the @core version of azure-functions-core-tools: npm i -g azure-functions-core-tools@core Then, add a new launch configuration for the 2.0 version of the Core Tools:
  • In project properties -> Debug, change Launch to Executable
  • For Executable, use %APPDATA%\npm\func.cmd
  • For Application Arguments, use host start
  • For working directory, use $(TargetDir)
F5 will now launch the new version of the Azure Functions Core Tools.

Running Functions 2.0 in Azure

You can also use the .NET Core 2.0 port in Azure by targeting the new Functions 2.0 preview runtime. To use it, select "beta" in Function app settings -> Runtime version. Alternatively, you can the app setting FUNCTIONS_EXTENSION_VERSION to the value beta. You will then see a different set of templates available in the Add New Function page. Since the 2.0 runtime is in preview, there may be breaking changes even in minor releases. So, the 2.0 runtime should not be used for production workloads. If you navigate to the root of you function app, you’ll see that you’re running the new version:

Connect with us

We've seen a lot of excitement and interest, so we're looking forward to getting your feedback as we finalize the Functions 2.0 runtime.
  • To report bugs or file feature requests, please open an issue on the Azure-Functions GitHub repo.
  • For technical questions, please post on the MSDN forums or StackOverflow. The entire Functions engineering team monitors these questions, so you’re sure to get an expert answer.
  • For product news, follow @AzureFunctions.