.NET Core 3.1 updates in Cloud Shell and App Engine flexible environment


.NET Core 3.1 updates on Google Cloud

.NET Core 3.1 was released on December 3rd, 2019 and is a LTS release, supported for three years.

In Google Cloud, you could already deploy .NET Core 3.1 containers in Cloud Run (see cloud-run-dotnetcore-31) and also in App Engine flexible environment with a custom runtime.

We recently extended .NET Core 3.1 support in a couple of ways:

  1. Cloud Shell now supports .NET Core 3.1.
  2. App Engine flexible environment runtime now supports .NET Core 3.1.

.NET Core 3.1 in Cloud Shell

Inside Cloud Shell, you can see the latest 3.1.301 version:

$ dotnet --version

3.1.301

Create an ASP.NET Core MVC app:

$ dotnet new mvc -o HelloWorldAspNetCore

Running 'dotnet restore' on HelloWorldAspNetCore/HelloWorldAspNetCore.csproj...
  Determining projects to restore...
  Restored /home/atameldev/HelloWorldAspNetCore/HelloWorldAspNetCore.csproj (in 221 ms).
Restore succeeded.

Run it inside Cloud Shell:

$ dotnet run --urls=http://localhost:8080

info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:8080

.NET Core 3.1 in App Engine flexible environment

You can now deploy .NET Core 3.1 apps to App Engine flexible environment without having to create a custom runtime.

First, publish a release version:

$ dotnet publish -c Release

HelloWorldAspNetCore -> /home/atameldev/HelloWorldAspNetCore/bin/Release/netcoreapp3.1/HelloWorldAspNetCore.dll
HelloWorldAspNetCore -> /home/atameldev/HelloWorldAspNetCore/bin/Release/netcoreapp3.1/HelloWorldAspNetCore.Views.dll
HelloWorldAspNetCore -> /home/atameldev/HelloWorldAspNetCore/bin/Release/netcoreapp3.1/publish/

Create an app.yaml file with the following contents inside the publish folder:

cat > bin/Release/netcoreapp3.1/publish/app.yaml << EOF
env: flex
runtime: aspnetcore
EOF

Deploy to App Engine:

gcloud app deploy bin/Release/netcoreapp3.1/publish/app.yaml

You can then browse to the app with gcloud app browse and see the default page:

.NET Core 3.1 on App Engine flexible environment

Codelab and GitHub Repo

If you want to try this out yourself, we also updated Deploy an ASP.NET Core app to App Engine codelab with the latest info:

Deploy an ASP.NET Core app to App Engine codelab

I also create a GitHub repo, appengine-flex-dotnetcore with code and instructions on the same.


If you have questions/comments, feel free to reach out to me on Twitter (@meteatamel).


See also