Develop Azure Functions using .NET Core 3.1
Tags: serverless, csharp, dotnet, azure
Published: 2019-10-17 20:15:35

---
title: Develop Azure Functions using .NET Core 3.1
published: true
description: Azure Functions 3.0 is now live, letting you develop and publish Azure Functions targeting .NET Core 3.1
tags: serverless, csharp, dotnet, azure
---

<< Updated on Dec 9 2019 with go-live announcement of Azure Functions on .NET Core 3.1 >>

We're extremely excited to announce you can now develop and publish Azure Functions built on top of the .NET Core 3.1 runtime.

## Things to know

Azure Functions 3.0 is now go-live and ready for production.  It is a highly backwards compatible release.  One of the immediate benefits of this release is you can write Azure Functions targeting `netcoreapp3.1`.  You should also be able to move existing ~2 apps to ~3 without issue.  A list of considerations on changes between 2.x and 3.x can [be found in our docs](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions#migrating-from-2x-to-3x).

You can write any Azure Function language in 3.0 (Java, JavaScript, PowerShell, TypeScript, Python) - though note some of the tooling and integrations will continue to receive updates until mid-January.  Instructions on changing your tools or apps to target 3.x for other languages [can be found in our docs](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions#locally-developed-application-versions).  For now let's walk through creating a .NET Core 3.1 app.

## Getting started

#### [Install the .NET Core 3.1 SDK](https://dotnet.microsoft.com/download)

#### Install the 3.x core tools (optional for Visual Studio development)

Using npm: 

```
npm install -g azure-functions-core-tools@3
```

Using brew:

```
brew tap azure/functions
brew install azure-functions-core-tools@3
# If you already have func installed
brew link --overwrite azure-functions-core-tools@3
```

#### Create an Azure Functions project

You have a few options here.  You could create a new project using our [Visual Studio](https://docs.microsoft.com/azure/azure-functions/functions-create-your-first-function-visual-studio), [Visual Studio Code](https://docs.microsoft.com/azure/azure-functions/functions-create-first-function-vs-code), or [CLI](https://docs.microsoft.com/azure/azure-functions/functions-run-local#create-a-local-functions-project) tools.  For other tools, once you install the 3.x core tools you should be set.  If attempting to target .NET Core 3.1 just be sure to update your .csproj file template with `netcoreapp3.1`.  Also be sure to target the ``Microsoft.NET.Sdk.Functions` package version of at least `3.0.1`.

##### Creating with Visual Studio 2019

If you want to develop using .NET Core 3.1, you must use Visual Studio 2019 16.4 or newer. 

1. Open Visual Studio and select to create a new Azure Functions project
    - You should see an indicator at the bottom as it downloads the runtime and templates of "Making sure all templates are up to date."  This could take a few minutes, but wait for it to finish.
2. Once the templates are up to date, go back one screen and forward so template options are refreshed.
3. Select the now available "Azure Functions v3" option from the template drop-down.
4. Create your project.
5. If you want to target .NET Core 3.1, edit the project properties and select .NET Core 3.1.

You should be set!  You can now debug, test, and publish this function.

#### Publish your Function App 

You can publish your function using the regular tools.  Depending on the tool you will likely see a prompt to update your `FUNCTIONS_EXTENSION_VERSION` application setting from the default `~2` to `~3`.  This does need to occur before a 3.x app can run successfully in Azure.

## Upgrading a v2 app to v3

If you have an existing app and want to test it out with the new release, the following settings would need to be modified:

### Non-.NET Functions

Locally once you start using the 3.x CLI your apps will debug and run in the 3.0 environment automatically.  For apps in the cloud, you simply need to update the app setting of `FUNCTIONS_EXTENSION_VERSION` to `~3` - but make sure to do some validation tests first before changing anything in production 😅.

### .NET Functions

If using Visual Studio, make sure you've already followed all of the steps in the "Creating with Visual Studio 2019" section to ensure you have the latest templates and project options available before attempting to upgrade.  You may need to go to the new app template screen to get the 3.x bits to pull in on your machine, so if you get an error like "no runtime available that matches the version," try creating a new 3.x app from scratch first to make sure VS has fetched all the latest bits.

To change a project between ~2 and ~3 locally, update the `.csproj` file of the project and change:

- `AzureFunctionsVersion` from `v2` to `v3`
- `Microsoft.NET.Sdk.Functions` package version to at least `3.0.1`
- Optionally, you can change to target `netcoreapp3.1` if you want to target the latest .NET Core version

You **should not** change the `host.json` version to `3.0`.  The `host.json` schema version is different than the function runtime version, and is still 2.0.

## Path to GA

While you can begin using 3.x in production today, we are tracking a few work items around tooling and platform features before we announce full GA for tools and runtime in January 2020.  You can see some of those work items called out [in GitHub](https://github.com/Azure/azure-functions-host/wiki/Functions-3.x-go-live-work-items)