The .NET runtime is the software stack responsible for installing your application code and dependencies, and then running that application in the flexible environment.
.NET Version 6 is built using
buildpacks which enables you to
choose an operating system. To use these new runtimes, you must
specify additional settings in your
Choose a .NET version
New runtime versions
.NET runtime version 6 runs on Ubuntu 22. For .NET runtime
version 6, you must include the
operating_system settings in your
to specify an operating system.
To use the new runtime, you must:
Update your project file.
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <None Update="app.yaml"> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </None> </ItemGroup> </Project>
For more information see Migrate from ASP.NET Core 3.1 to 6.0.
Install gcloud CLI version 420.0.0 or later. You can update your CLI tooling by running the gcloud components update command. To view your installed version, you can run the gcloud version command.
operating_systemsetting in your
runtime: aspnetcore env: flex runtime_config: operating_system: "ubuntu22"
Previous runtime versions
To target a specific .NET SDK version, update your project file. For more information, see Migrate from ASP.NET Core 3.1 to 6.0.
If you want to use GKE or other Docker hosts, you need to create a Dockerfile that copies your application code and installs dependencies. For more information, see Custom Runtimes.
Deploy your App Engine app
To deploy your .NET app:
Run the following commands from the root directory where your app resides:
v6 and later
gcloud app deploy
v3.1 and earlier
dotnet restore dotnet publish -c Release gcloud app deploy
HTTPS and forwarding proxies
App Engine terminates the HTTPS connection at the load balancer and forwards the
request to your application. Applications can examine the
observe whether the original protocol was HTTP or HTTPS.
Some applications also need to ascertain the user's IP address. This is
available in the standard
Extending the runtime
The flexible environment .NET runtime can be used to create a custom runtime.
Custom runtimes are configured via a
You can customize the
.dockerignore as desired. Finally,
you will need to specify
runtime: custom instead of
runtime: aspnetcore in
Customizing the .NET Runtime
for more information.
The following environment variables are set by the runtime environment:
||The name of the current instance.|
||The amount of memory available to the application process.|
||The service name specified in your application's
||The version label of the current application.|
||The Project ID associated with your application, which is visible in the Google Cloud console|
||The port that will receive HTTP requests.|
You can set additional configuration variables with
Each instance of your application can use the Compute Engine metadata server to query information about the instance, including its host name, external IP address, instance ID, custom metadata, and service account information. App Engine does not allow you to set custom metadata for each instance, but you can set project-wide custom metadata and read it from your App Engine and Compute Engine instances.
This example function uses the metadata server to get the external IP address of the instance:
var metadataClient = Google.Cloud.Metadata.V1.MetadataClient.Create(); var result = await metadataClient.GetMetadataAsync( "instance/network-interfaces/0/access-configs/0/external-ip"); return result.Content.ToString();