JAMStack on .NET : Hosting on Vercel
Posted 18 Nov 2021
Vercel (formerly known as Zeit) are the people behind Next.js and offer a very nice platform to deploy and run JAMStack sites. But how does it deal with a .NET based JAMStack site?
In a nutshell
Vercel has a very complete offering including some of the more advanced features like edge caching of your API requests.
Building .NET is not included but can be configured for the build pipelines. At runtime there is no .NET support. On the other hand, it has a CLI, allowing you to build anywhere and deploy to the site.
|Integrated build||✔||Very extensible|
|Deploy from Github Actions||✔||Via 3rd party open-source actions or by pushing the site into a branch|
|Deploy from Azure Pipelines||➖||Could probably make this work using Vercel CLI|
|Deploy from CLI||✔||Requires a bit of config but works well|
|VS Code extensions||➖||Nothing substantial|
|CLI tooling||✔||Very good|
|Serverless functions||✔||Node, Go, Python, Ruby|
|Proxy API calls||✔||Through serverless functions or edge functions.|
|Custom 404||✔||Provide a 404.html or use a function|
|Authentication||➖||Needs 3rd party solution, you'll need to do a bit of dev work.|
|CDN||✔||Included and controllable|
|Cost||✔||Free tier to get started and pretty decent ramp up for commercial use|
With a little bit of tweaking, Vercel can build .NET Core and later. The excellent documentation mentions the build runs Amazon Linux 2 containers which apparently is very similar to Cent OS. And indeed the instructions for installing the .NET SDK on Cent OS work.
.NET works at build-time only. You'll have to user one of the natively supported languages if you want to implement functions or other server logic.
Under the Build & Development Settings for your project set the Framework preset to Other and override the settings. For example, for a static website using Statiq the following settings will work:
|Build Command||dotnet run --configuration Release|
|Install Command||rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm && yum install dotnet-sdk-3.1 -y|