How to Deploy Dot Net API on Debian 12

STEP 1: Install .NET Runtime

wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

install SDK

sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0

Cehck this link for further information. Check dotnet version

dotnet -version

STEP 2: Download Code

Doenload API code on Server. In my case I have my code in /opt/dotnetAPI/

STEP 3: Create Service file

cat /etc/systemd/system/callhome-bill-api.service

unit file to start .net code

[Unit]
Description=API
Wants=network.target
After=network.target

[Service]
Environment="ASPNETCORE_URLS=http://*:5000"
Environment="ASPNETCORE_WEBROOT=/opt/dotnetAPI/"
Environment="ASPNETCORE_CONTENTROOT=/opt/dotnetAPI/"
ExecStart=/usr/bin/dotnet /opt/dotnetAPI/API.dll
ExecStop=/bin/kill ${MAINPID}
Restart=on-failure
RestartSec=5s
Type=simple

[Install]
WantedBy=multi-user.target

Dot Net Envoirnmnet Variables

Check this link for compiling dotnet code on linux

Enjoy ;)

No comments:

Post a Comment

SIPp UAC Scenario to send RTP

Please install the latest sipp ( >=3.7.3 ) wget https://github.com/SIPp/sipp/releases/download/v3.7.3/sipp chmor +x sipp mv sipp /usr/bin...