In production environment and for optimal runtime performance, you should publish Web APIs to the dedicated server, such as Kestrel (with or without a reverse proxy).
The following section provides detailed instructions on how to run Web APIs with Kestrel in the production environment.
For instructions on running Web APIs in other production environments, refer to Hosting Web APIs in Docker Containers, Hosting Web APIs in IIS, Deploying installable cloud apps to Kubernetes, Publishing PowerServer Projects to Azure App Service, and Publishing PowerServer Projects to Azure Container Instances.
To run PowerServer Web APIs on Kestrel in the production environment:
-
Go to the PowerServer C# solution > ServerAPIs > bin > Release (or Debug) > net6.0 folder (for example, C:\Users\appeon\source\repos\salesdemo_cloud\ServerAPIs\bin\Release\net6.0).
When the PowerServer C# solution is generated, the Web APIs is compiled (with Debug or Release mode) and all files (such as configuration files, assembly files, dependencies, .NET runtime etc.) required to run the app are included.
-
Copy all files from the folder to the production server.
-
Run the ServerAPIs.exe file in the same folder, in the following ways:
-
Method 1: Run the app by executing the following command:
ServerAPIs.exe --urls "http://<hostname>:<port>"
Or
dotnet ServerAPIs.dll --urls "http://<hostname>:<port>"
Make sure to specify the IP address or domain and port number correctly. Note that if you don't specify the "--urls" argument, PowerServer Web APIs and Kestrel will by default run on localhost (which is http://localhost:5000 or https://localhost:5001). That means PowerServer Web APIs cannot be accessed remotely.
Make sure the API console window displays the following messages:
-
"Now listening on: http://x.x.x.x:yyyy" -- This is the root URL of the PowerServer Web APIs. You can verify that this URL is accessible in your network environment by running http://x.x.x.x:yyyy/health-ui/, for example, http://172.16.100.35:80/health-ui/.
-
"Application started" -- The Web APIs is started successfully.
-
"Hosting environment: Production" -- The Web APIs is currently running in the production environment.
-
-
Method 2: Run the app as a service just like how you run any other ASP.NET Core app, so that it can be automatically run without needing you to log into the PC to start it.
To run the PowerServer Web APIs as a service in Windows, refer to https://docs.microsoft.com/aspnet/core/host-and-deploy/windows-service&tabs=visual-studio.
To run the PowerServer Web APIs as a service in Linux, refer to https://docs.microsoft.com/aspnet/core/host-and-deploy/linux-nginx#create-the-service-file.
-