Preface
Testing and developing Google Cloud Functions via the Cloud Console is tedious, as the function has to be redeployed after every change to the code.
Google’s documentation
https://cloud.google.com/functions/docs/running/overview
for local development of Google Cloud Functions is somewhat simplistic and difficult to follow in places. Therefore here are my instructions for C#
General
Download dotnet-sdk-3.1
dotnet new --install Google.Cloud.Functions.Templates
dotnet new gcf-http
The project gets the name of the parent folder
Local with Functions Framework
Just
dotnet run
Local with Docker / Cloud Native Buildpacks
Install ‚pack‘:
https://buildpacks.io/docs/tools/pack/
Create Docker image:
pack build --builder gcr.io/buildpacks/builder:v1 --env GOOGLE_RUNTIME=dotnet --env GOOGLE_FUNCTION_SIGNATURE_TYPE=http --env GOOGLE_FUNCTION_TARGET=TestGcpLocalCloudFunction01.Function test-gpc-local-function-01
TestGcpLocalCloudFunction01 is the name of the project / namespace in C#. Function is the name of the class.
It is essential to note that the name of the image test-gpc-local-function-01 is lowercase.