Quickstart for .NET in the App Engine Flexible Environment

This quickstart shows you how to create a small App Engine app that displays a short message.

Before you begin

Before running and deploying this sample, take the following steps:

  1. Use the GCP Console to create a new GCP project, create an App Engine app, and enable billing:
    Go to App Engine

    When prompted, select the region where you want your App Engine app located and then enable billing.

  2. Install the following prerequisites locally:
    1. Download and install the Cloud SDK. Follow the instructions in the Cloud SDK page to initialize and set your GCP project ID in the gcloud command-line tool:
      Download the SDK
    2. Install the .NET Core SDK, LTS version.
    3. If you are using Visual Studio, you must use version 2015 or later.
      • Images are available for ASP.NET Core apps written for .NET Core 1.0, 1.1, 2.0 and 2.1.
    4. To deploy to App Engine directly from Visual Studio, install Cloud Tools for Visual Studio.

App Engine locations

App Engine is regional, which means the infrastructure that runs your apps is located in a specific region and is managed by Google to be redundantly available across all the zones within that region.

Meeting your latency, availability, or durability requirements are primary factors for selecting the region where your apps are run. You can generally select the region nearest to your app's users but you should consider the location of the other GCP products and services that are used by your app. Using services across multiple locations can affect your app's latency as well as pricing.

App Engine is available in the following regions:

  • northamerica-northeast1 (Montréal)
  • us-central (Iowa)
  • us-west2 (Los Angeles)
  • us-east1 (South Carolina)
  • us-east4 (Northern Virginia)
  • southamerica-east1 (São Paulo) *
  • europe-west (Belgium)
  • europe-west2 (London)
  • europe-west3 (Frankfurt)
  • asia-northeast1 (Tokyo)
  • asia-east2 (Hong Kong)
  • asia-south1 (Mumbai)
  • australia-southeast1 (Sydney)

* For customers using the São Paulo region, all regional product SLAs remain in force. However, multi-region and cross-region functionality that span across North America and South America might temporarily have reduced availability or performance.

You cannot change an app's region after you set it.

If you already created an App Engine application, you can view the region by running the gcloud app describe command or opening the App Engine Dashboard in the GCP Console. The region of your App Engine application is listed under http://[YOUR_PROJECT_ID].appspot.com.

This quickstart assumes that you are familiar with building web apps with C#.

Download the Hello World app

We've created a simple Hello World app for .NET so you can quickly get a feel for deploying an app to the App Engine flexible environment. The Hello World app is similar to the app created by Visual Studio when an empty ASP.NET core app is created. The sample app adds an app.yaml file. The app.yaml file is an App Engine configuration file that specifies your runtime and other App Engine settings.

  1. Download the sample app and extract it.

  2. If you're using the command line, navigate to the app directory, dotnet-docs-samples\appengine\flexible\HelloWorld.

Run Hello World on your local machine

Visual Studio

To run the Hello World app on your local computer:

  1. Open dotnet-docs-samples\appengine\flexible\HelloWorld\HelloWorld.sln with Visual Studio.
  2. Press F5.

    You can see the "Hello World" message from the sample app displayed in the page.

Command Line

To run the Hello World app on your local computer:

  1. Run the following commands from the dotnet-docs-samples\appengine\flexible\HelloWorld directory:
    dotnet restore
    dotnet run
  2. In your web browser, go to http://localhost:5000/

    You can see the "Hello World" message from the sample app displayed in the page.

  3. In your terminal window, press Ctrl+C to exit the web server.

Deploy and run Hello World on App Engine

Visual Studio

To deploy the Hello World app:

  1. Open dotnet-docs-samples\appengine\flexible\HelloWorld\HelloWorld.sln with Visual Studio.
  2. In Solution Explorer, right-click HelloWorld, and choose Publish to Google Cloud...
  3. Click App Engine Flex.
  4. Click Publish.
  5. To see your deployed app, go to the following address in your browser:

Command Line

  1. Run the following commands from the dotnet-docs-samples\appengine\flexible\HelloWorld directory:
    dotnet restore
    dotnet publish -c Release
    gcloud app deploy .\bin\Release\netcoreapp1.0\publish\app.yaml
  2. Launch your browser and view the app at http://YOUR_PROJECT_ID.appspot.com.
    gcloud app browse
This time, the page that displays the Hello World message is delivered by a web server running on an App Engine instance.

Congratulations! You've deployed your first .NET app to App Engine flexible environment!

See the following sections for information about cleaning up as well as links to the possible next steps that you can take.

Clean up

To avoid incurring charges, you can delete your GCP project to stop billing for all the resources used within that project.

  1. In the GCP Console, go to the Projects page.

    Go to the Projects page

  2. In the project list, select the project you want to delete and click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

What's next

Learn the whole platform

Now that you know what it's like to develop and deploy App Engine apps, you can stretch out and see the rest of GCP. You already have the Cloud SDK installed and that gives you the tools to interact with products like Cloud SQL, Cloud Storage, Cloud Datastore, and more.

For a guided walkthrough that teaches you how to create an app that uses the entire platform, not just App Engine, check out our quickstart on creating the Bookshelf app.

Learn about the App Engine flexible environment

Here are some topics to help continue your learning about App Engine.

Hello World code review

Hello World is the simplest possible App Engine app, as it contains only one service, has only one version, and all of the code is located within the app's root directory. This section describes each of the app files in detail.


The Hello World app is a simple ASP.NET application:

    public class Startup
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            if (env.IsDevelopment())

            app.Run(async (context) =>
                await context.Response.WriteAsync("Hello World!");


The app.yaml file describes an application's deployment configuration:

runtime: aspnetcore
env: flex

# This sample incurs costs to run on the App Engine flexible environment. 
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
  instances: 1
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

Here, app.yaml specifies the runtime used by the app, and sets env: flex, specifying that the app uses the flexible environment.

Was this page helpful? Let us know how we did:

Send feedback about...

App Engine flexible environment for .NET docs