Releasing an WebAPI
So I have finished my application, everything works and it has been tested…. but what now? I am somewhat new to C# and I have never been in a position that I am in now.
I have a Windows server that is meant to constantly run this API, so how do I get this application out of VS? Normally I would just copy and .exe of the release build of my apps and run it like that, but that doesn’t seem to work.
This sounds like a thing any C# dev should know but I can’t find anything on the web, probably because "I am searching wrong", I would be really thankful I someone would show me where I can learn this part of development 😀
EDIT: Thank you all for suggestions, I feel like I left out important information about the goals of my API. This API would run locally on my companies network, my employees have a good VPN on all of our devices and they are the only ones who would use the API anyways, so I felt like running it locally is the way to go for now.
Solution – 1
There are a lot of things that go into this, but with just the information you have given so far, I would suggest reading this article on publishing your API to your server.
Solution – 2
You’re looking for how to "Publish". This article https://www.c-sharpcorner.com/UploadFile/3d39b4/publish-and-host-Asp-Net-web-api/ will get you most of the way I’d say.
In a (really) rough summary:
- Publish your code which will create the files you need a "publish" folder in the source project
- Set up a site in IIS on the server (I guess you might need to set up a database too)
- Copy the files to the server and make any changes you need to appsettings.json for things like db connection strings.
Solution – 3
The main issue with deployment is:
- Will you do API versioning?
- How you will maintain the code?
- What happens when you change the code e.g. fix a bug or add a new features?
- What happens when the new code does not work and you deploy it accidentally, how do you rollback it?
- What kind of shutdown time is allowed?
- Do you need continuous integration?
- Do you need docker?
- Do you need cloud?
People usually write automated deploy code nowadays, so it is not as simple as just running the code on an IIS server normally, though it depends on project size or how serious you and your bosses take it.
REST API versioning: https://www.xmatters.com/blog/blog-four-rest-api-versioning-strategies/
MsDeploy to IIS: https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/deploying-web-packages https://dennistretyakov.com/setting-up-msdeploy-for-ci-cd-deployments-to-iis
CI servers: https://www.ahmetkucukoglu.com/en/how-to-publish-asp-net-core-application-by-using-jenkins https://www.alibabacloud.com/help/en/web-app-service/latest/08d871 https://octopus.com/docs/guides/deploy-aspnet-app/to-iis/using-octopus-onprem-teamcity-builtin