Home > Blockchain >  Releasing an WebAPI
Releasing an WebAPI

Time:10-22

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 :D

CodePudding user response:

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:

  1. Publish your code which will create the files you need a "publish" folder in the source project
  2. Set up a site in IIS on the server (I guess you might need to set up a database too)
  3. Copy the files to the server and make any changes you need to appsettings.json for things like db connection strings.

CodePudding user response:

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.

CodePudding user response:

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?
  • etc...

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

Cloud: https://learn.microsoft.com/en-us/azure/devops-project/azure-devops-project-aspnet-core

Some db versioning tools: https://www.liquibase.org/ http://dbdeploy.com/ https://flywaydb.org/

  • Related