AWS Lambda to IIS (.NET core Web APIs)
http://gitlab.crimsoni.com/SampleProjects/EnagoInquiryPage/commit/c4e0f0cecd06ed51f4d84929229c4ff2ff0e5f3c)
Step 1: Migrate code from AWS lambda to IIS configuration (1.1 Rename LocalEntryPoint class and filename to Program and Program.cs respectively.
1.2 Delete LambdaEntryPoint.cs from the project.
1.3 Move any configuration from environment.yml to appsetting.json and set the environment variables inside Startup.cs. Also add logging logLevel configuration in appsetting.json.
1.4 Remove AWS Lambda references from csproj file. Add Logging.Console package reference and fire a dotnet restore.
1.5 set up logging in startup.cs file.
1.6 set up AWS credentials from the appsettings.json file.
1.7 Modify web.config file
Step 2: Prepare build
2.1 - Publish site
dotnet publish -o published //Publish to published folder
2.2 - Copy web.config manually to the published folder
2.3 - copy the published site to hosting server
2.4 - Edit the appsettings.json with correct aws credentials.
2.5 - create "logs" folder and give necessary permissions.
Step 3: Prepare hosting environment
3.1 Install .NET Core windows server hosting bundle
3.2 Install the required .NET core version for the project. The above step (Step 3.1) installs the latest .NET core version. If this matches the one used in the project, this step can be skipped. Download the installer from the below link https://github.com/dotnet/core/blob/master/release-notes/download-archive.md
3.4 Create a Website/Web application in IIS which points to the published code (Step 2.3) with .NET Framework version of the application pool set to "No Managed Code".
3.5 Run the application.
Debugging steps:
3.3 To test step 3
3.3.1 Open command prompt and enter the below command
dotnet
This command should show usage options for the dotnet command.
3.3.2 In IIS, select the website/web application and go to Handler Mappings. "aspNetCore" mapping should be visible. This handler is added in the web.config file of the project.
3.3.3 Check logs folder for any logs. For any IIS errors, please check the EventViewer.
References:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x