The Cloud Functions .NET runtime is based on .NET Core 3.1. For instructions on how to prepare your local machine for .NET development, see Setting up a .NET development environment.
To get started with .NET on Cloud Functions, see the Quickstart.
Template package
The template package helps you to create new functions. To use it:
Install .NET Core SDK 3.1.
Install the template package:
dotnet new -i Google.Cloud.Functions.Templates::1.0.0-beta04
Templates are provided for the three kinds of functions in C# (the default), F#, and Visual Basic. When creating a new project from a template, specify -lang f#
to create an F# project, or -lang vb
to create a Visual Basic project. For more information, see:
- Your First Function: C#
- .NET Languages (for F# and Visual Basic)
Selecting the runtime
You can select the .NET runtime for your function during deployment.
gcloud
If you are using the gcloud
command-line tool, you can specify the runtime
by using the --runtime
parameter. The --entry-point
flag specifies the
fully qualified class name (FQN). For example:
gcloud functions deploy NAME --entry-point FQN --runtime dotnet3 --trigger-http
For more arguments that you can specify when you are deploying, see Deploy using the gcloud tool.
Console
If you are using the Cloud Console, you can select the runtime when you create and deploy a function.
In the Cloud Console, go to the Cloud Functions Overview page.
Go to the Cloud Functions Overview page
Make sure that the project for which you enabled Cloud Functions is selected.
Click Create Function, and follow the steps to create your function.
When prompted to specify a runtime, select .NET Core 3.1.
Execution environment
The execution environment includes the runtime, the operating system, and a library that invokes your function.
The .NET runtime uses an execution environment based on Ubuntu 18.04 with .NET Core 3.1. See Cloud Functions Execution Environment for more information.
The library that invokes your function is the .NET Functions Framework.
Source code structure
In order for Cloud Functions to find your function's definition, each runtime has certain structuring requirements for your source code. See Writing Cloud Functions for more information.
Specifying dependencies
You can specify dependencies for your function by adding them to a project file. For more information, see Specifying dependencies in .NET.
What's next
- Create your first C# function from scratch.
- Learn about the other .NET languages you can use to write Cloud Functions: F# and Visual Basic.