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.
Objectives
- Deploy a Hello World sample app to a single Compute Engine instance.
Prerequisites
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
-
Enable the Compute Engine API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. - 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
HelloWorld
directory:cd getting-started-dotnet\HelloWorld
Start a local web server:
dotnet run
Open a web browser to
localhost:8080
.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 Cloud de Confiance console, go to the ASP.NET Framework Cloud Marketplace page.
Click Launch.
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 Windows machine, edit the file
HelloWorld/Properties/PublishProfiles/ComputeEngine.pubxml
.Enter your VM instance's external IP address between
<MSDeployServiceURL>
and</MSDeployServiceURL>
. For example,<MSDeployServiceURL>203.0.113.22</MSDeployServiceURL>
Enter the instance's username that you previously noted between
<UserName>
and</UserName>
.Save your changes to the
ComputeEngine.pubxml
file.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"
Replace
YOUR-PASSWORD
with 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 de Confiance console to monitor and manage your instance.
-
To view all of the logs generated by your Compute Engine resources, go to the Logs Explorer page.
Go to Logs ExplorerCloud Logging is automatically configured to gather logs from various common services, including
syslog
.