The story of switching the Azure App Service web system from Windows to Linux

Overview

I was running my own website with Azure App Service, but in order to do custom domain and SSL binding, I need to select a plan of ** about 7,000 yen a month **, so I can not expect profits I thought that the system was a little expensive, but I learned that Linux would be a little cheaper, so I decided to switch.

Below, the structure of the self-made website

front end Vue.js
Back end .Net Core 3.1(C#)
Database SQLServer
CI/CD AzureDevopsPipelines
SSL certificate Let’s Encrypt
Other services used BlobStorage、SendGrid

Difference between "Windows" and "Linux" of App Service

I don't know if it can be done for the time being, but I decided to make it once, so I created AppService (Linux). When I glanced at the contents, the following functions cannot be used on Linux.

I can't use the extension. .. .. So, do I have to manually install "Let's Encrypt"? .. .. Premonition of turbulence. .. .. (In the Windows version, it could be easily applied using the extension "Azure Let's Encrypt")

I'll try it anyway

Since I created the service for the time being, I was able to deploy the source, set the configuration information, and start it without any problems. The custom domain setting method is the same as in Windows, so you can complete it without any problems.

So, the last difficulty, manually getting an SSL certificate by "Let's Encrypt"

Install Certbot

SSH connection to the corresponding App Service (possible from Azure portal) and execute the following command

$ apt-get update
$ apt-get install certbot

You should now have Certbot installed.

Issuance of certificate

Use Certbot to issue the certificate. Execute the following command in SSH as before

certbot certonly -d <domain> --manual --preferred-challenges dns

The "--preferred-challenges dns" part is the selection of the authentication method.

This time, I decided to authenticate by adding a TXT record to the domain for which I want to obtain a certificate called ** DNS Challenge **. (There are other ** Https challenge ** etc. that place a file in a specific location and refer to it)

As you proceed with the command, you will be instructed to "Create a TXT record using this value in DNS", so follow the instructions. Even if you create a TXT record, it will not be reflected for about 5 minutes, so check that it is reflected with the following command before proceeding.

nslookup -q=TXT [domain]

If the following character string is displayed, it is successful.

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/[domain]/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/[domain]/privkey.pem
   Your cert will expire on <some-date>. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Creating a private certificate

Create a private certificate using the intermediate certificate obtained from Let's Encrypt.

$ mkdir /tmp/sandbox -p
$ cd /tmp/sandbox

$ SOURCE=/etc/letsencrypt/live/[domain]
$ sudo cp $SOURCE/{cert.pem,privkey.pem,chain.pem} .

$ sudo chown ope *.pem

$ openssl pkcs12 -export -out certificate.pfx -inkey privkey.pem -in cert.pem -certfile chain.pem

When you execute the last ** openssl ** command, you will be asked to set a password, so enter it. Remember the password you enter here as it will be required when you register the certificate with AppService.

Settings for App Service

Download the created pfx file and SSL binding from the AppService custom domain to the target domain. This completes the work!

At the end

When operating in a company etc., it is convenient to use ** Application Insight ** or analysis tools, but I personally thought that Linux would be fine if it was a small site operated by an individual. How about running .Net Core on a Linux server? .. .. I was thinking, but I'm glad that it worked normally. (However, I felt a little lighter than Windows. Is it because of my mind?)

It was ** about 7,000 yen a month ** for a Windows server, but ** about 2000 yen a month ** for a Linux server ** !! If this is the case, I think it's okay to start up some more servers and create a WEB service.

Recommended Posts

The story of switching the Azure App Service web system from Windows to Linux
After all, the story of returning from Linux to Windows
Deploy from GitHub Actions to Azure App Service
The story of moving from Pipenv to Poetry
The story of switching from WoSign to Let's Encrypt for a free SSL certificate
Sample to put Python Flask web app on Azure App Service (Web App)
The story of copying data from S3 to Google's TeamDrive
[Linux] I tried to summarize the command of resource confirmation system
A story about switching a personally developed Web service from a rental server to GCP (Google Cloud Platform)
How to operate Linux from the console
The story of running the asp.net core 3.1 app on arm64 version Amazon Linux 2
The story of pep8 changing to pycodestyle
[Amazon Linux] Switching from Python 2 series to Python 3 series
SSH login to the target server from Windows with a click of a shortcut
Add Windows to the Linux OS boot menu
Change the decimal point of logging from, to.
From the introduction of pyethapp to the execution of contract
Try to simulate the movement of the solar system
The story of Linux that I want to teach myself half a year ago
[Note] The story of setting up the SDK for Python of Azure IoT Hub on Linux
The story of porting code from C to Go and getting hooked (and to the language spec)
The story of launching a Minecraft server from Discord
How to know the port number of the xinetd service
The story of stopping the production service with the hostname command
The story of replacing Nvidia GTX 1650 with Linux Mint 20.1.
The story of building the fastest Linux environment in the world
Open Chrome version of LINE from the command line [Linux]
The story of wanting to buy Ring Fit Adventure
The story of using circleci to build manylinux wheels
I tried to rewrite the WEB server of the normal Linux programming 1st edition with C ++ 14
Implementation of recommendation system ~ I tried to find the similarity from the outline of the movie using TF-IDF ~
A story about porting the code of "Try and understand how Linux works" to Rust
The story of sys.path.append ()
[Linux] Copy data from Linux to Windows with a shell script
The story of introducing jedi (python auto-completion package) to emacs
The story of a Django model field disappearing from a class
How to calculate the amount of calculation learned from ABC134-D
How to hit NAPALM from the Web (NetDevOpsSec reality solution)
A rough summary of the differences between Windows and Linux
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
How to ssh into Azure App Service and enable venv
Commands and files to check the version of CentOS Linux
The story that CSS is no longer applied after uploading the Django app from local to AWS