Running an ASP.NET Core Web Application on Alibaba Cloud Elastic Computing Service (ECS)

Why Alibaba Cloud ECS?

  1. Create new Alibaba Cloud ECS Instance.
  2. Create a new .Net Core Web Application using Microsoft Visual Studio.
  3. Log into ECS Instance.
  4. Install .NET Core Runtime on ECS.
  5. Deploy Source Code to ECS Instance.
  6. Configure Nginx.
  7. Run Application.

Create a New .NET Core Web Application using Microsoft Visual Studio

  1. Open Visual Studio. Go to File > New Project. Under the C# node, select Web, then select ASP.NET Core Web Application. Give your application any name. (Do not include spaces in name).
  2. Click Ok, then select Web Application (Model — View — Controller). Leave Authentication to No Authentication. Click Okay.
  3. Run the Application and confirm that it runs on localhost in your browser.
  4. Commit your code and push to GitHub (or any Repository Service).

Log into ECS Instance

  1. Go to the console, Click on your ECS Instance.
  2. Under Configuration Information, copy the Internet IP Address. It should look this this: 47.89.106.74
  3. Open your terminal and type ssh root@YOUR_IP_ADDRESS. (Replace YOUR_IP_ADDRESS with the Instance Internet IP Address.
  4. You will see a warning, answer yes. Enter your set password. You should now see your ECS Welcome Message.

Install .NET Core Runtime on ECS

wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1

Deploy Source Code to ECS Instance

sudo apt-get install libunwind8
git clone https://github.com/vnwonah/AlibabaCloudECSDeploy
cd AlibabaCloudECSDeploy/AlibabaCloudECSDeploy
dotnet publish -c Release -o ./published -r linux-x64

Configure Nginx

[Unit] 
Description=Alibaba Cloud Net Core App
[Service]
WorkingDirectory=/root/netcoreapp
ExecStart=/usr/bin/dotnet /root/AlibabaCloudECSDeploy/ALibabaCloudECSDeploy/AppName.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-core-app
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Analyzing Hot and Cold Tables with MaxCompute

Empline — Tryhackme

Video User Network Profiling and Its Application

正式面試前目標

Automating the Deployment of Infrastructure Using Terraform on GCP

How to Install and Configure Buildbot on CentOS 7

How to Use Python Generators to Efficiently Process Large Data Sets

Lessons from digitizing chemical industry

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Containerized Automation

Build and publish Docker images with GitHub Actions

GitLab CI CD Pipeline Tutorial

How to Collect Log from PostgreSQL & MongoDB to Elasticsearch using Logstash and Filebeat ?