App Engine quickstart using .NET
Learn how to deploy a .NET sample app to App Engine.
</walkthrough-tutorial-url> <!--
-->
Take the interactive version of this tutorial, which runs in the Cloud Console:
​​
​
​
</walkthrough-alt>

Introduction

This tutorial shows you how to deploy a sample application to App Engine using the gcloud command.
Here are the steps you will be taking.
    Create a project
    Projects bundle code, VMs, and other resources together for easier development and monitoring.
    Build and run your "Hello, world!" app
    You'll learn how to run your app using Cloud Shell, right in your browser. At the end, you'll deploy your app to the web using the gcloud command.
    After the tutorial...
    Your app will be real and you'll be able to experiment with it after you deploy, or you can remove it and start fresh.

Project setup

Google Cloud organizes resources into projects, which collect all of the related resources for a single application in one place.
Begin by creating a new project or selecting an existing project for this tutorial.
</walkthrough-project-setup>
For details, see Creating a project.

Using Cloud Shell

Cloud Shell is a built-in command-line tool for the console. We're going to use Cloud Shell to deploy our app.

Open Cloud Shell

Open Cloud Shell by clicking the </walkthrough-cloud-shell-icon>Activate Cloud Shell button in the navigation bar in the upper-right corner of the console.

Clone the sample code

Use Cloud Shell to clone and navigate to the "Hello World" code. The sample code is cloned from your project repository to the Cloud Shell.
If the directory already exists, remove the previous files before cloning.
1
git clone https://github.com/GoogleCloudPlatform/dotnet-docs-samples
Copied!
Then, switch to the tutorial directory:
1
cd dotnet-docs-samples/appengine/flexible/HelloWorld
Copied!

Configuring your deployment

You are now in the main directory for the sample code. We'll look at the files that configure your application.

Exploring the application

Enter the following command to view your application code:
1
cat Startup.cs
Copied!

Exploring your configuration

App Engine uses YAML files to specify a deployment's configuration. app.yaml files contain information about your application, like the runtime environment, URL handlers, and more.
Enter the following command to view your configuration file:
1
cat app.yaml
Copied!
The syntax of this file is YAML. For a complete list of configuration options, see the app.yaml reference.

Testing your app

Test your app on Cloud Shell

Cloud Shell lets you test your app before deploying to make sure it's running as intended, just like debugging on your local machine.
To test your app, enter the following:
1
dotnet restore
Copied!
1
ASPNETCORE_URLS="http://*:8080" dotnet run
Copied!

Preview your app with "Web preview"

Your app is now running on Cloud Shell. You can access the app by clicking the Web preview​
</walkthrough-web-preview-icon> button at the top of the Cloud Shell pane and choosing Preview on port 8080.

Terminating the preview instance

Terminate the instance of the application by pressing Ctrl+C in the Cloud Shell.

Deploying to App Engine

Create an application

If you already created an app, you can skip this step.
To deploy your app, you need to create an app in a region:
1
gcloud app create
Copied!

Deploying with Cloud Shell

You can use Cloud Shell to deploy your app. To deploy your app, enter the following:
1
dotnet publish -c Release
Copied!
1
gcloud app deploy ./bin/Release/netcoreapp2.1/publish/app.yaml
Copied!

Visit your app

Congratulations! Your app has been deployed. The default URL of your app is a subdomain on appspot.com that starts with your project's ID: .
Try visiting your deployed application.

View your app's status

You can check in on your app by monitoring its status on the App Engine dashboard.
Open the Navigation menu in the upper-left corner of the console.
Then, select the App Engine section.
</walkthrough-menu-navigation>

Disable your project

    1.
    Go to the Settings page.

Conclusion

</walkthrough-conclusion-trophy>
You have successfully deployed an App Engine application!
Here are some next steps for building your next application and learning to use App Engine with other Google Cloud products:
Download the Cloud SDK and develop locally
Install the Cloud SDK on your local machine.
Build your next application
Learn how to use App Engine with other Google Cloud products:
<walkthrough-tutorial-card url=https://cloud.google.com/appengine/docs/flexible/dotnet/using-cloud-sql icon="SQL_SECTION" label="cloudSql"> Learn to use Cloud SQL. Cloud SQL is a fully-managed, relational MySQL database for your applications. </walkthrough-tutorial-card>Learn more in the Cloud SQL documentation.</walkthrough-alt>
<walkthrough-tutorial-card url=https://cloud.google.com/appengine/docs/flexible/dotnet/using-cloud-storage icon="STORAGE_SECTION" label="cloudStorage"> Learn to use Cloud Storage. Cloud Storage is a powerful and simple object storage service. </walkthrough-tutorial-card>Learn more in the Cloud Storage documentation.</walkthrough-alt>
Last modified 7mo ago