Before Azure Kubernetes Services
How .NET Core APIs are Deployed on Windows Server 2022
Introduction
Deploying .NET Core APIs on Windows Server 2022 is a streamlined process that involves preparing the server, publishing the API, and configuring IIS. This guide will walk you through each step to ensure a successful deployment.
Prerequisites
- Windows Server 2022 installed and configured.
- .NET Runtime and ASP.NET Core Hosting Bundle installed.
- Internet Information Services (IIS) installed.
- Administrative access to the server.
Step 1: Publish the .NET Core API
First, publish your API using the following command in the project directory:
dotnet publish -c Release -o ./publish
This will generate the files required for deployment in the publish
folder.
Step 2: Install the .NET Hosting Bundle
Download and install the latest ASP.NET Core Hosting Bundle from the official .NET website. This bundle includes the necessary components to run your API under IIS.
Step 3: Configure IIS
- Open IIS Manager (
inetmgr
). - Right-click on Sites and select Add Website.
- Provide a site name, specify the path to the published API, and assign a port or binding.
- Ensure the application pool uses No Managed Code.
Step 4: Configure Application Settings
Ensure the appsettings.json
is configured correctly. You can also add environment variables using IIS Manager.
Step 5: Test and Troubleshoot
- Browse to the API URL (e.g.,
http://localhost:5000
). - Check logs in the
Event Viewer
or thelogs
folder. - Verify firewall rules and bindings.
Conclusion
By following these steps, you can deploy and manage .NET Core APIs efficiently on Windows Server 2022. With IIS, you gain robust application management and monitoring capabilities.
Comments
Post a Comment