Deploy ASP.NET app to Windows Server on Compute Engine

1. Overview

ASP.NET is an open source web framework for building modern web apps and services with .NET. ASP.NET creates websites based on HTML5, CSS, and JavaScript that are simple, fast, and can scale to millions of users.

In this lab, you deploy a simple ASP.NET app to Windows Server running on Compute Engine. This codelab builds on the Deploy Windows Server with ASP.NET Framework to Compute Engine codelab. You might want to complete that lab first.

Additionally, you will need Visual Studio 2013 or later to write your ASP.NET app and deploy it to Compute Engine.

What you'll learn

  • How to create a simple ASP.NET app.
  • How to run the ASP.NET app locally in Visual Studio.
  • How to deploy and run your ASP.NET app to a Windows Server on Compute Engine.

What you'll need

How will you use this tutorial?

Read it through only Read it and complete the exercises

How would rate your experience with Google Cloud Platform?

Novice Intermediate Proficient

2. Setup and Requirements

Self-paced environment setup

You should already have your Google Cloud Platform project from the previous lab, so there is no need to create a new project. Sign-in to Google Cloud Platform console ( and select the project from the previous lab.

3. Download the ASP.NET app

Download the sample as a zip file and extract it.

Alternatively, you can clone its git repository.

git clone

Either way, you should have a getting-started-dotnet folder with the following contents.


4. Run the application locally

Double click aspnet\1-hello-world\hello-world.sln. This opens the solution in Visual Studio.


Take a look at WebApiConfig.cs. It includes a simple HelloWorld HTTP handler.

public class HelloWorldHandler : HttpMessageHandler
  protected override Task<HttpResponseMessage> SendAsync(
       HttpRequestMessage request,
       CancellationToken cancellationToken)
    return Task.FromResult(new HttpResponseMessage()
      Content = new ByteArrayContent(Encoding.UTF8.GetBytes("Hello World."))

In Visual Studio, press F5 to build and run the application. After Visual Studio downloads NuGet dependencies and builds the app, you should see a Hello World message pop up in your browser.


Once you're certain that the app is running locally, press Shift + F5 to stop the application.

5. Deploy Windows Server with ASP.NET Framework

In this section, we'll learn how to create a new Google Compute Engine virtual machine instance with Windows Server and ASP.NET Framework installed using Cloud Marketplace from Google Cloud Console.

Log into Google Cloud Console

Navigate to Google Cloud Console from another browser tab or window, to Use the login credentials you have set up when you signed up for Google Cloud Platform or those given to you by the lab proctor.


In Google Cloud Console, click the Menu icon for Products & services in the top left of the screen:


Then navigate to Cloud Marketplace


Search for ASP.NET Framework

Type ASP.NET to search for ASP.NET Framework and then click on the result box below.


Launch on Compute Engine

In the next screen, click on Launch on Compute Engine.

There are many parameters you can configure when creating a new instance. Let's use the following:



Deployment Name



europe-west1-dLearn more about zones in Regions & Zones documentation.

Machine Type

1 vCPU (n1-standard-1)The n1-standard-1 is more than sufficient for our ASP.NET website, with 1 core and 3.75GiB of RAM. However, you can select smaller or larger machines, going all the way up to 32-core / 208GiB RAM. Learn more about this and custom machine types in the Machine Types documentation.Note: A new project has a default resource quota, which may limit the number of CPU cores. You can request more for your projects.

Windows Server OS Version


Boot Disk Type

Standard persistent diskNote: You may optionally choose a more performant, solid state disk drive (SSD). See Storage Options.

Disk size in GB

100We're using the default of 100GB, but you may adjust it to more or less depending on your needs.


Allow HTTP traffic
Allow HTTPS traffic
Allow WebDeploy traffic
Allow RDP trafficKeep the defaults which will create firewall rules to allow HTTP, HTTPS traffic along with WebDeploy and RDF traffic.

Click on Deploy to create the new virtual machine instance with Windows Server and ASP.NET Framework! This will take you to a new page where you can see the progress.


Once finished, go to Compute Engine from the menu on the left and then select VM Instances. You should see the new virtual machine in the VM Instances list.


If you click on External IP, you should also see the default IIS website served from the instance.


Note that you can also Remote Desktop (RDP) into the machine but we need to create a Windows user and password first.

6. Create a Windows user and password

To create a Windows user and password, select Create or reset Windows password.


This will open a new window where you can create a user. Keep the default and select Set. After a few seconds, you should have a New Windows password dialog with the newly created password. Make a note of the password, as you will need it in the next section.

7. Deploy the application to your Windows Server on Compute Engine

It's time to deploy your application to a Windows Server running on a Compute Engine instance.

First, you need to find the external IP of the Compute Engine instance that you deployed in Deploy Windows Server with ASP.NET Framework to Compute Engine. In the Cloud Console, go to Compute > VM Instances, find your instance and note its external IP address.


Now, you will need the Windows username and password you created in the previous step.

In Visual Studio Solution Explorer, right-click on your project and select Publish in the context menu.


In the Publish Web dialog, select Custom as your publish target.

In the New Custom Profile dialog, provide a name for the deployment profile, and click OK.

Fill out your profile as follows.


The external IP address of your Compute Engine instance. This address can be found on the VM instances page in the Cloud Console. The IP address is ephemeral, which is sufficient for our purposes.

Site Name

Default Web SiteNote: The site name you provide here must match the name that appears in IIS Manager on your Compute Engine instance.


The username of the Windows user account you created on your Compute Engine instance.


The password of the Windows user account you created on your Compute Engine instance.

Destination URL

http://Note: The destination URL is the address where your page will be accessible after it is deployed.

Click Validate Connection to ensure that the properties are correct.


Because the Microsoft IIS installation in your deployment uses a self-signed certificate by default, you'll see a Certificate Error during the validation process. Check the box to Save this certificate for future sessions of Visual Studio, and click Accept to accept the certificate.


If your configuration is valid, click Settings. Click File Publish Options, and check Remove additional files at destination. This is important for later steps when you publish new web sites to the same Compute Engine instance.


Click Publish to deploy the application. After publishing completes, Visual Studio opens the application in your default web browser.


8. Cleanup

That's it! Now it's time to clean up the resources you used (to save on cost and to be a good cloud citizen).

You can either delete the instances or simply stop them, although keep in mind that stopped instances can still incur costs related to storage.


Of course, you can also delete the entire project but you will lose any billing setup you have done (disabling project billing first is required). Additionally, deleting a project only stops it from being billed once the current billing cycle ends.

9. Congratulations!

Google Compute Engine is the foundation to Google Cloud Platform's Infrastructure-as-a-Service. As you've seen, it is quite easy to deploy an ASP.NET app to Windows Server on Compute Engine.

What we've covered

  • How to create a simple ASP.NET app.
  • How to run the ASP.NET app locally in Visual Studio.
  • How to deploy and run your ASP.NET app to a Windows Server on Compute Engine.

Next Steps


This work is licensed under a Creative Commons Attribution 2.0 Generic License.