Asp net core 6 application not using correct port when hosted in azure app servi

Introduction

ASP.NET is a popular programming language used for building web applications. It provides a framework for developing websites, web , and web APIs. One common issue that face is when an ASP.NET Core 6 application does not use the correct port when hosted in Azure App Service.

Description

When hosting an ASP.NET Core 6 application in Azure App Service, the application may not use the correct port specified in the configuration. This can lead to unexpected behavior and errors when trying to access the application.

Solution

To solve this issue, you need to that the application is to use the correct port when hosted in Azure App Service. Here are the to follow:

Step 1: Check the Configuration

First, check the configuration of your ASP.NET Core 6 application. Open the appsettings.json file and look for the urls key. This key specifies the URLs and ports that the application should listen on. Make sure that the correct port is specified in this configuration.


{
  "urls": "http://localhost:5000"
}

Step 2: Configure Azure App Service

Next, configure Azure App Service to use the correct port. Open the Azure and navigate to your App Service. Go to the Configuration section and add a new application setting with the key ASPNETCORE_URLS and the value set to the correct port.

Step 3: Restart the App Service

After making the configuration , restart the Azure App Service to apply the new settings. This will ensure that the application uses the correct port when hosted in Azure.

Example

Here is an example of how the ASP.NET Core 6 application configuration should look like in the appsettings.json file:


{
  "urls": "http://localhost:5000"
}

And here is an example of how to configure the Azure App Service:


ASPNETCORE_URLS = http://localhost:5000

By these steps and ensuring that the correct port is configured both in the application and in Azure App Service, you should be able to resolve the issue of the ASP.NET Core 6 application not using the correct port when hosted in Azure App Service.

Conclusion

Configuring the correct port for an ASP.NET Core 6 application hosted in Azure App Service is essential for ensuring the proper functioning of the application. By following the steps outlined in this article, you can resolve the issue and ensure that your application uses the correct port when hosted in Azure.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents