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.
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
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:
Selecting the runtime
You can select the .NET runtime for your function during deployment.
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.
If you are using the Cloud Console, you can select the runtime when you create and deploy a function. See the Cloud Console quickstart for detailed instructions.
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.
You can specify dependencies for your function by adding them to a project file. For more information, see Specifying dependencies in .NET.
- Create your first C# function from scratch.
- Learn about the other .NET languages you can use to write Cloud Functions: F# and Visual Basic.