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.
Deployment
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 |
Tooling
VS Code extensions | ➖ | Nothing substantial |
CLI tooling | ✔ | Very good |
Hosting
Serverless functions | ✔ | Node, Go, Python, Ruby |
Extensionless urls | ✔ | |
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 |
General
Documentation | ✔ | Excellent |
Cost | ✔ | Free tier to get started and pretty decent ramp up for commercial use |
.NET support
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:
Setting | Value |
Build Command | dotnet run --configuration Release |
Output Directory | output |
Install Command | rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm && yum install dotnet-sdk-3.1 -y |
Conclusion
Vercel gets a thumbs up for excellent docs and flexibility. The platform is geared towards javascript based development but, with a bit of configuration, works well for .NET generated sites. You'll have to back the site with an API hosted elsewhere if you want that in .NET as well.
Further reading
ANSELMO CASTRO
hello friend thank you very much for the information. I tested but inside the vercel my project gave this "Error: Command "dotnet run --configuration Release", has another way to perform the "Build Command" ?