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

Author: [Mete Atamel](https://atamel.dev/) | Published: 2020-06-29 | Updated: 2020-07-05 | Topics: dotnet, dotnetcore, google cloud, app engine | Canonical: https://atamel.dev/posts/2020/06-29_dotnetcore31-cloudshell-appengine-flex/


## .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](https://github.com/meteatamel/cloud-run-dotnetcore-31))
and also in App Engine flexible environment with a [custom
runtime](https://cloud.google.com/appengine/docs/flexible/custom-runtimes).

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:

```sh
$ dotnet --version

3.1.301
```

Create an ASP.NET Core MVC app:

```sh
$ 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:

```sh
$ 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:

```sh
$ 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:

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

Deploy to App Engine:

```sh
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](/img/2020/dotnetcore31-app-engine-flex.png)

## Codelab and GitHub Repo

If you want to try this out yourself, we also updated [Deploy an ASP.NET Core app to App
Engine](https://codelabs.developers.google.com/codelabs/cloud-app-engine-aspnetcore)
codelab with the latest info:

[![Deploy an ASP.NET Core app to App Engine codelab](/img/2020/deploy-aspnetcore-app-engine-flex-codelab.png)](https://codelabs.developers.google.com/codelabs/cloud-app-engine-aspnetcore)

I also create a GitHub repo,
[appengine-flex-dotnetcore](https://github.com/meteatamel/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](https://twitter.com/meteatamel)).

