Press "Enter" to skip to content

Posts tagged as “.net core deploy”

How to deploy .Net core application on Ubuntu (Google Cloud)

We can run an application developed with Net Core on Windows, Linux, and Mac systems. In this article we will publish an application developed with Net Core 2.1 version on Ubuntu 16.04 using nginx.

It is pretty easy but there is no good documentation on internet. I want to write an article about this. Here are my steps to deploy .net core application on google cloud! Thanks for reading..

Deploying .Net Core App on Google Cloud (ubuntu)

  • Create Ubuntu instance from Google Cloud
    • Ubuntu 18.04 LTS version
  • Set firewall rules to instance’s Network Tags (Following tags should be exist in the Google Cloud “Network Services/Firewall Rules”)
    • http-server
    • https-server
    • default-allow-ssh
    • vnc-server (if you want RDP)
  • Login gcloud
    • gcloud auth login
  • Open ssh console
    • gcloud compute ssh YOUR_INSTANCE_NAME –project YOUR_PROJECT_NAME –zone europe-west4-a –ssh-flag “-L 22:localhost:22”
  • File transfer to ubuntu pc
    • gcloud compute scp C:\Users\YOURNAME\Desktop\publish\*.* YOUR_INSTANCE_NAME 
      YOUR_PROJECT_NAME YOUR_ZONE (example: zone europe-west4-a)
  • Install .Net Core SDK and Runtime to the Ubuntu 18.04 instance 
    • Update Ubuntu
      • sudo apt-get update
      • sudo apt-get upgrade
    • Install .net core package
  • Set firewall settings
    • sudo ufw enable
    • sudo ufw allow https
    • sudo ufw allow ssh
    • sudo ufw allow http
  • Create Folder on Ubuntu Instance
    • sudo mkdir YOUR_FOLDER_NAME
  • Copy project files to instance (in the Google Cloud SDK Command Line Toot, not ubuntu shell)
    • gcloud compute scp C:\ProjectFolder\*.* 
      YOUR_INSTANCE_NAME  –project 
  • Create .ppk file
    • you need to create .ppk file with PuTTY Key Generator
    • Create a .ppk file with a same name with the instance of linux machine. For Example; your linux machine name: sample-ubuntu, and your .ppk file name must be ‘sample-ubuntu.ppk’
    • Key Comment: Your sample-ubuntu machine user name
      Key passphrase: Your password& save private key as  sample-ubuntu.ppk
  • Create sh file ( file in the Your publish folder)

                                  #! /bin/sh

                                  sudo dotnet /YourProject/YourProject.dll

  • Create service file (yourproject.service file in the Your publish folder)

                                 Description= yourproject daemon service

                                 ExecStart=/ YourProject/



  • Set permission
    • sudo chmod +x YourProject.dll
    • sudo chmod +x
  • Copy service file to linux system folder
    • sudo cp yourproject.service /lib/systemd/system
  • Reload SystemD and enable the service
    • sudo systemctl daemon-reload
    • sudo systemctl enable yourproject
  • Start service
    • sudo systemctl start yourproject
      • sudo systemctl stop yourproject
  • View service status
    • systemctl status yourproject

Your application is now running on your linux machine. You can check your server by entering the IP address of your server. The service definition file that we created will start automatically even when our server restarts or the dotnet runtime collapses.

As you, if you can follow steps deploying .net core app on google cloud, it is so easy.

you can ask every thing to us from