The .NET runtime

Note: Some.NET runtimes have reachedend of support. You cannot re-deployversions that use runtimes after their end of support date. We recommend thatyouupgrade your appto use the latest version of .NET.

The .NET runtime is the software stack responsible forinstalling your application code and dependencies, and then running thatapplication in the flexible environment.

.NET versions

.NET 8 is built usingbuildpacks. For the full list of supported.NET versions, and their corresponding Ubuntuversion, see theRuntime support schedule.

To use asupported.NET version, you must:

  • Update your project file with the .NET version you want to use.

    <Project Sdk="Microsoft.NET.Sdk.Web">  <PropertyGroup>    <TargetFramework>net8.0</TargetFramework>    <Nullable>enable</Nullable>    <ImplicitUsings>enable</ImplicitUsings>  </PropertyGroup>  <ItemGroup>    <None Update="app.yaml">      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>    </None>  </ItemGroup></Project>

    For more information seeMigrate from ASP.NET Core 3.1 to 6.0.

  • Install gcloud CLI version420.0.0 or later. You can update yourCLI tooling by running thegcloud components updatecommand. To view your installed version, you can run thegcloud version command.

  • Specify theoperating_system setting in yourapp.yaml file:

    runtime:aspnetcoreenv:flexruntime_config:operating_system:"ubuntu22"
  • Optionally, you can specify a runtime version by including theruntime_versionsetting in yourapp.yaml file. By default, App Engine uses the latestavailable LTS .NET version if theruntime_version setting is not specified.For example, theapp.yaml file looks as follows when specifying.NET 8 on Ubuntu 22:

    runtime:aspnetcoreenv:flexruntime_config:runtime_version:"8"operating_system:"ubuntu22"

Previous runtime versions

Warning: .NETversion 3 and earlier have reached end of support.App Engine blocks you from deploying your applications using runtimes that havereached end of support. We recommend that you migrate your app to use asupported versionof .NET or use acustom runtime.

To target a specific .NET SDK version, update your project file. For moreinformation, seeMigrate from ASP.NET Core 3.1 to 6.0.

If you want to use GKE or other Docker hosts, you need to create aDockerfile that copies your application code and installsdependencies. For more information, seeCustom Runtimes.

To deploy your .NET app, run the following commands from theroot directory where your app resides:

    dotnet restore    dotnet publish -c Release    gcloud app deploy

Support for other .NET runtimes

If you need to use a .NET version that isn'tsupported, you can create acustom runtime and select avalid base image with the .NET version you need.

For Google-supplied base images orDocker .NET base images,seeBuilding custom runtimes.

HTTPS and forwarding proxies

App Engine terminates the HTTPS connection at the load balancer and forwards therequest to your application. Applications can examine theX-Forwarded-Proto toobserve whether the original protocol was HTTP or HTTPS.

Some applications also need to ascertain the user's IP address. This isavailable in the standardX-Forwarded-For header.

Extending the runtime

The flexible environment .NET runtime can be used to create a custom runtime.Custom runtimes are configured via aDockerfile.

You can customize theDockerfile and.dockerignore as desired. Finally,you will need to specifyruntime: custom instead ofruntime: aspnetcore inapp.yaml. SeeCustomizing the .NET Runtimefor more information.

Environment variables

The following environment variables are set by the runtime environment:

Environment variableDescription
GAE_INSTANCEThe name of the current instance.
GAE_MEMORY_MBThe amount of memory available to the application process.
GAE_SERVICEThe service name specified in your application'sapp.yaml file, or if no service name is specified, it is set todefault.
GAE_VERSIONThe version label of the current application.
GOOGLE_CLOUD_PROJECTThe Project ID associated with your application, which is visible in the Google Cloud console
PORTThe port that will receive HTTP requests.

You can set additional configuration variables withappsettings.json.

Metadata server

Each instance of your application can use theCompute Engine metadata server toquery information about the instance, including its host name, external IPaddress, instance ID, custom metadata, and service account information. AppEngine does not allow you to set custom metadata for each instance, but you cansetproject-wide custom metadataand read it from your App Engine and Compute Engine instances.

This example function uses the metadata server to get the external IP address ofthe instance:

varclient=newHttpClient();client.DefaultRequestHeaders.Add("Metadata-Flavor",new[]{"Google"});response=awaitclient.GetStringAsync("http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip");

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.