This tutorial shows how to get started with Compute Engine. Follow this tutorial by deploying a Hello World .NET web app to Compute Engine. For help getting started with App Engine, see the App Engine standard environment.
- Deploy a Hello World sample app to a single Compute Engine instance.
This tutorial uses the following billable components of Google Cloud:
Before you begin
登录您的 Google 帐号。
如果您还没有 Google 帐号，请注册新帐号。
在 GCP Console 的项目选择器页面上，选择或创建 GCP 项目。
确保您的 Google Cloud Platform 项目已启用结算功能。 了解如何确认您的项目已启用结算功能。
- 启用Compute EngineAPI。
- Install .NET Core SDK 2.1 or later on your local machine running Microsoft Windows.
- Install Web Deploy 3.6 or later on your local machine running Microsoft Windows.
Running the app locally
Download and unzip or clone the sample repository from github:
git clone https://github.com/GoogleCloudPlatform/getting-started-dotnet.git
In a PowerShell window, go into the
Start a local web server:
Open a web browser to
In your web browser, you see some Hello World text, served from your local machine.
When you're ready to move on, stop the local web server by pressing Control+C.
Deploying to a single instance
This section walks you through running a single instance of your app on Compute Engine.
Create and configure a Compute Engine instance
From Google Cloud Marketplace, you can launch an instance of Windows running Microsoft IIS on Compute Engine.
In the Google Cloud Console, go to the ASP.NET Framework Google Cloud Marketplace page.
Click Launch on compute engine.
Leave the settings set to their default values, and click Deploy.
Wait for the Compute Engine instance to deploy. It usually takes about 5 minutes to deploy.
To display resource information, click VM instance.
To edit the VM instance, click Manage Resource.
Click Set Windows password, and then make a note of the username.
Copy the new Windows password, and then click Close.
In the VM instance details page, make a note of the external IP address.
On your local machine, edit the file
Enter your VM instance's external IP address between
</MSDeployServiceURL>. For example,
Enter the instance's username that you previously noted between
Save your changes to the
In a PowerShell window, publish your app to the Compute Engine instance:
dotnet publish -c Release ` /p:PublishProfile=Properties\PublishProfiles\ComputeEngine.pubxml ` "/p:Password=YOUR-PASSWORD"
YOUR-PASSWORDwith the password you previously copied.
Open a web browser to your instance's external IP address.
In your web browser, you see some Hello World text, served from your Compute Engine instance.
Manage and monitor an instance
You can use the Cloud Console to monitor and manage your instance.
To avoid incurring charges to your Google Cloud Platform account for the resources used in this tutorial:
Delete the project
- In the Cloud Console, go to the Manage resources page.
- In the project list, select the project that you want to delete and then click Delete delete.
- In the dialog, type the project ID and then click Shut down to delete the project.
Delete the individual resources
gcloud compute instances delete my-app-instance --zone=YOUR_ZONE --delete-disks=all gcloud compute firewall-rules delete default-allow-http-80
Try out other Google Cloud features for yourself. Have a look at our tutorials.
For other .NET resources for building your apps, see the following: