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](https://docs.cloud.google.com/dotnet/getting-started/tutorial-app).

## Objectives

- Deploy a Hello World sample app to a single Compute Engine instance.

## Costs


In this document, you use the following billable components of Google Cloud:


- [Compute Engine](https://cloud.google.com/compute/all-pricing)


To generate a cost estimate based on your projected usage,
use the [pricing calculator](https://docs.cloud.google.com/products/calculator).
New Google Cloud users might be eligible for a [free trial](https://docs.cloud.google.com/free).

<br />

## Before you begin

1. Install [.NET
   Core SDK 2.1](https://dotnet.microsoft.com/download/dotnet-core/2.1) or later on your local machine running [Microsoft Windows](https://www.microsoft.com/en-us/windows).
2. Install [Web Deploy
   3.6](https://www.iis.net/downloads/microsoft/web-deploy) or later on your local machine running [Microsoft Windows](https://www.microsoft.com/en-us/windows).


## Running the app locally


1. [Download and unzip](https://github.com/GoogleCloudPlatform/getting-started-dotnet/archive/master.zip) or clone the sample repository from github:

       git clone https://github.com/GoogleCloudPlatform/getting-started-dotnet.git

2. In a PowerShell window, go into the `HelloWorld` directory:

       cd getting-started-dotnet\HelloWorld

3. Start a local web server:

       dotnet run

4. Open a web browser to `localhost:8080`.

   In your web browser, you see some Hello World text, served from your
   local machine.
5. When you're ready to move on, stop the local web server by pressing
   <kbd>Control+C</kbd>.

<br />

## Deploying to a single instance


This section walks you through running a single instance of your app
on Compute Engine.

![Single-instance deployment.](https://docs.cloud.google.com/static/languages/images/compute-single-instance.svg)


### Create and configure a Compute Engine instance


From Google Cloud Marketplace, you can launch an instance of Windows running Microsoft IIS on Compute Engine.

1. In the Google Cloud console, go to the **ASP.NET Framework** Cloud Marketplace page.

   [Go to Cloud Marketplace](https://docs.cloud.google.com/console/marketplace/details/click-to-deploy-images/aspnet)
2. Click **Launch**.

3. 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.
4. To display resource information, click **VM instance**.

5. To edit the VM instance, click **Manage Resource**.

6. Click **Set Windows password**, and then make a note of the username.

7. Copy the new Windows password, and then click **Close**.

8. In the **VM instance details** page, make a note of the external IP address.

9. On your local Windows machine, edit the file `HelloWorld/Properties/PublishProfiles/ComputeEngine.pubxml`.

10. Enter your VM instance's external IP address between `<MSDeployServiceURL>`
    and `</MSDeployServiceURL>`. For example, `<MSDeployServiceURL>203.0.113.22</MSDeployServiceURL>`

11. Enter the instance's username that you previously noted between `<UserName>` and `</UserName>`.

12. Save your changes to the `ComputeEngine.pubxml` file.

13. 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.
14. 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.

<br />

### Manage and monitor an instance

You can use the Google Cloud console to monitor and manage your instance.

1. To view all of the logs generated by your Compute Engine resources,
   go to the **Logs Explorer** page.

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)


   [Cloud Logging](https://docs.cloud.google.com/logging) is automatically configured to gather logs from
   various common services, including `syslog`.

<br />

<br />

## Clean up


To avoid incurring charges to your Google Cloud account for the resources used in this
tutorial, either delete the project that contains the resources, or keep the project and
delete the individual resources.

### Delete the project

> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

1. In the Google Cloud console, go to the **Manage resources** page.

   [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
2. In the project list, select the project that you want to delete, and then click **Delete**.
3. In the dialog, type the project ID, and then click **Shut down** to delete the project.

### Delete the individual resources

```bash
gcloud compute instances delete my-app-instance --zone=YOUR_ZONE --delete-disks=all
gcloud compute firewall-rules delete default-allow-http-80
```

## What's next

-

  Explore reference architectures, diagrams, and best practices about Google Cloud.
  Take a look at our
  [Cloud Architecture Center](https://docs.cloud.google.com/architecture).

- For other .NET resources for building your apps, see the following:

  - Manage and monitor your Instance Group deployment at [Compute Engine \> Instance groups](https://console.cloud.google.com/compute/instanceGroups).
  - Manage your load balancing configuration, including URL maps and backend services, at [Network services \> Load balancing](https://console.cloud.google.com/net-services/loadbalancing/list).
  - [Deploy an app to Google Kubernetes Engine](https://docs.cloud.google.com/kubernetes-engine/docs/quickstarts/deploy-app-container-image)
  - Explore other [Google Cloud services](https://docs.cloud.google.com/).