[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003eThe .NET runtime in the flexible environment manages the installation and execution of your application's code and dependencies, with .NET 8 utilizing buildpacks.\u003c/p\u003e\n"],["\u003cp\u003eTo use a specific supported .NET version, update your project file with the desired version, ensure you have gcloud CLI version 420.0.0 or later, and define the \u003ccode\u003eoperating_system\u003c/code\u003e and optionally \u003ccode\u003eruntime_version\u003c/code\u003e in your \u003ccode\u003eapp.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eOlder .NET versions, specifically 3 and earlier, have reached their end of support, and deploying applications with these runtimes is blocked; upgrading to a supported version is recommended.\u003c/p\u003e\n"],["\u003cp\u003eFor .NET versions not directly supported, custom runtimes can be created by selecting a valid base image with the required .NET version, or by using Docker to deploy your application.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine uses environment variables like \u003ccode\u003eGAE_INSTANCE\u003c/code\u003e, \u003ccode\u003eGAE_SERVICE\u003c/code\u003e, and \u003ccode\u003ePORT\u003c/code\u003e to provide information about your application instance, and applications can query the Compute Engine metadata server for more details.\u003c/p\u003e\n"]]],[],null,["# The .NET runtime\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n| **Note:** Some [.NET runtimes](/appengine/docs/flexible/lifecycle/support-schedule#net) have reached [end of support](/appengine/docs/flexible/lifecycle/runtime-lifecycle#end_of_support). You cannot re-deploy versions that use runtimes after their end of support date. We recommend that you [upgrade your app](/appengine/docs/flexible/dotnet/runtime#newversions) to use the latest version of .NET.\n\n\u003cbr /\u003e\n\nThe .NET runtime is the software stack responsible for\ninstalling your application code and dependencies, and then running that\napplication in the flexible environment.\n\n.NET versions\n-------------\n\n.NET 8 is built using\n[buildpacks](/docs/buildpacks/overview). For the full list of supported\n.NET versions, and their corresponding Ubuntu\nversion, see the [Runtime support schedule](/appengine/docs/flexible/lifecycle/support-schedule#net).\n\nTo use a [supported](/appengine/docs/flexible/lifecycle/support-schedule#net)\n.NET version, you must:\n\n- Update your project file with the .NET version you want to use.\n\n \u003cProject Sdk=\"Microsoft.NET.Sdk.Web\"\u003e\n\n \u003cPropertyGroup\u003e\n \u003cTargetFramework\u003enet8.0\u003c/TargetFramework\u003e\n \u003cNullable\u003eenable\u003c/Nullable\u003e\n \u003cImplicitUsings\u003eenable\u003c/ImplicitUsings\u003e\n \u003c/PropertyGroup\u003e\n\n \u003cItemGroup\u003e\n \u003cNone Update=\"app.yaml\"\u003e\n \u003cCopyToPublishDirectory\u003ePreserveNewest\u003c/CopyToPublishDirectory\u003e\n \u003c/None\u003e\n \u003c/ItemGroup\u003e\n\n \u003c/Project\u003e\n\n For more information see [Migrate from ASP.NET Core 3.1 to 6.0](https://learn.microsoft.com/en-us/aspnet/core/migration/31-to-60?view=aspnetcore-6.0&tabs=visual-studio.).\n- Install gcloud CLI version **420.0.0 or later** . You can update your\n CLI tooling by running the [gcloud components update](/sdk/gcloud/reference/components/update)\n command. To view your installed version, you can run the\n [gcloud version](/sdk/gcloud/reference/version) command.\n\n- Specify the `operating_system` setting in your [`app.yaml`](/appengine/docs/flexible/reference/app-yaml) file:\n\n runtime: aspnetcore\n env: flex\n\n runtime_config:\n operating_system: \"ubuntu22\"\n\n- Optionally, you can specify a runtime version by including the `runtime_version`\n setting in your `app.yaml` file. By default, App Engine uses the latest\n available LTS .NET version if the `runtime_version` setting is not specified.\n For example, the `app.yaml` file looks as follows when specifying\n .NET 8 on Ubuntu 22:\n\n runtime: aspnetcore\n env: flex\n\n runtime_config:\n runtime_version: \"8\"\n operating_system: \"ubuntu22\"\n\nPrevious runtime versions\n-------------------------\n\n| **Warning:** .NET **version 3 and earlier** have reached end of support. App Engine blocks you from deploying your applications using runtimes that have reached end of support. We recommend that you migrate your app to use a [supported version](/appengine/docs/flexible/lifecycle/support-schedule#net) of .NET or use a [custom runtime](/appengine/docs/flexible/custom-runtimes/about-custom-runtimes).\n\nTo target a specific .NET SDK version, update your project file. For more\ninformation, see [Migrate from ASP.NET Core 3.1 to 6.0](https://learn.microsoft.com/en-us/aspnet/core/migration/31-to-60?view=aspnetcore-6.0&tabs=visual-studio.).\n\nIf you want to use GKE or other Docker hosts, you need to create a\nDockerfile that copies your application code and installs\ndependencies. For more information, see\n[Custom Runtimes](/appengine/docs/flexible/custom-runtimes).\n\nTo deploy your .NET app, run the following commands from the\nroot directory where your app resides: \n\n dotnet restore\n dotnet publish -c Release\n gcloud app deploy\n\nSupport for other .NET runtimes\n-------------------------------\n\nIf you need to use a .NET version that isn't [supported](/appengine/docs/flexible/lifecycle/support-schedule#net), you can create a\n[custom runtime](/appengine/docs/flexible/custom-runtimes/build) and select a\nvalid base image with the .NET version you need.\n\nFor Google-supplied base images or\n[Docker .NET base images](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-8.0),\nsee [Building custom runtimes](/appengine/docs/flexible/custom-runtimes/build#base).\n\nHTTPS and forwarding proxies\n----------------------------\n\nApp Engine terminates the HTTPS connection at the load balancer and forwards the\nrequest to your application. Applications can examine the `X-Forwarded-Proto` to\nobserve whether the original protocol was HTTP or HTTPS.\n\nSome applications also need to ascertain the user's IP address. This is\navailable in the standard `X-Forwarded-For` header.\n\nExtending the runtime\n---------------------\n\nThe flexible environment .NET runtime can be used to create a custom runtime.\nCustom runtimes are configured via a `Dockerfile`.\n\nYou can customize the `Dockerfile` and `.dockerignore` as desired. Finally,\nyou will need to specify `runtime: custom` instead of `runtime: aspnetcore` in\n`app.yaml`. See\n[Customizing the .NET Runtime](/appengine/docs/flexible/dotnet/customizing-the-dotnet-runtime)\nfor more information.\n\nEnvironment variables\n---------------------\n\nThe following environment variables are set by the runtime environment:\n\nYou can set additional configuration variables with `appsettings.json`.\n\nMetadata server\n---------------\n\nEach instance of your application can use the\n[Compute Engine metadata server](/compute/docs/storing-retrieving-metadata) to\nquery information about the instance, including its host name, external IP\naddress, instance ID, custom metadata, and service account information. App\nEngine does not allow you to set custom metadata for each instance, but you can\nset [project-wide custom metadata](/compute/docs/storing-retrieving-metadata#projectwide)\nand read it from your App Engine and Compute Engine instances.\n\nThis example function uses the metadata server to get the external IP address of\nthe instance: \n\n var client = new HttpClient();\n client.DefaultRequestHeaders.Add(\"Metadata-Flavor\", new[] { \"Google\" });\n response = await client.GetStringAsync(\n \"http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip\");"]]