# Deploy on Google Cloud using a Windows Environment

This topic explains how to deploy the JSViewer_MVC sample on Google Cloud platform using Google Compute Engine environment.

## Content

In this tutorial we will be deploying our JSViewer\_MVC sample on Google Cloud platform using **Google Compute Engine** environment. The approach we are using to deploy the application is to create a VM Instance and then publish the application using Web Server (IIS).

### Setup Google Cloud

1. Sign in or create a new account on [Google Cloud Platform](https://console.cloud.google.com/).
2. Go to the Project Selector in the **Google Cloud Console** and create a new Project.
    Here we are naming the project as JSViewer MVC.
3. Make sure that billing is enabled for your Cloud project. Learn how to [check if billing is enabled on a project](https://docs.cloud.google.com/billing/docs/how-to/verify-billing-enabled).
4. From Console, go to the API Library and enable the 'Compute Engine API'.

### Setup Visual Studio

1. Open Visual Studio 2019.
2. Go to **Extensions** \> **Manage Extensions**.
3. Search online and install **Google Cloud Tools for Visual Studio**.

### Setup your application

1. Download the [JSViewer_MVC](https://github.com/activereports/WebSamples19/tree/main/JSViewer_MVC) sample from our [WebSamples19](https://github.com/activereports/WebSamples19) GitHub repository.
2. Open the application in Visual Studio and build and run the application.
3. Remove the **Reports** folder containing links the reports from the project since we will be embedding the reports in the application.
4. Now add a new folder and name it 'Reports'.
5. Add all the files from **JSViewerReports** in the **Reports** folder and set the **Build Action** as 'Embedded Resource'.
6. Run the application.

### Create and configure a Compute Engine instance

1. Navigate to [Google Cloud Console](https://console.cloud.google.com) from another browser tab or window, to [https://console.cloud.google.com](https://console.cloud.google.com).
2. In the Google Cloud console, go to the ASP.NET Framework [Cloud Marketplace](https://console.cloud.google.com/marketplace/details/click-to-deploy-images/aspnet) page.
3. Click **Launch**.
4. 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.
5. Once finished, go to **Compute Engine** from the menu on the top left and select **VM Instances**. A new virtual machine should be added in the VM Instances list.
6. Open the External IP in a new browser tab. You should also see the default IIS website served from the instance.
7. Now we will create a Windows user and password to access the VM Instance in Visual Studio.
    1. Click on RDP >**Set Windows** password, then make note of the username.
    2. Copy the new Windows password and save it somewhere secure.
    3. Click **Close**.

### Deploy the application

Now that we have configured our Compute Engine Instance, we are ready to deploy our application.

1. In **Visual Studio**, go to **Solution Explorer**, right-click on your project and select **Publish** in the context menu.
    ![Visual Studio Solution Explorer Publish option](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/project-publish.png)
2. Click on **Web Server (IIS)**.
    ![Web Server (IIS)](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/webserver-iis.png)
3. Select **Web Deploy**.
    ![Web Deploy](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/webserver-deploy.png)
4. Configure the Web Server with the following details.
    ![Configure Web Server (IIS) Connection](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/webserver-iisconnection.png)

    | Server | The external IP address of your Compute Engine instance. This address can be found on the VM instances page in the Cloud Console. |
    | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
    | Site Name | **Default Web Site**<br>Note: The site name you provide here must match the name that appears in IIS Manager on your Compute Engine instance. |
    | Username | The username of the Windows user account you created on your Compute Engine instance. |
    | Password | The password of the Windows user account you created on your Compute Engine instance. |
    | Destination URL | http://... . The destination URL is the address where your page will be accessible after it is deployed. |
5. Click **Validate Connection**.
    Because the Microsoft IIS installation in your deployment uses a self-signed certificate by default, you will 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.
6. 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.
    ![Publish Settings](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/publish-web-config.png)
7. Click **Publish** to deploy the application.

![Deploy on Google Cloud](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/devops/google-deploy-using-windows.png)

### Clean Up

To avoid incurring charges, you can delete the instances or simply stop them, although keep in mind that stopped instances can still incur costs related to storage.
You can also delete your Cloud project to stop billing for all the resources used within that project.

1. In the Cloud console, go to the **Manage resources** page.
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.