Azure Functions Dotnet Isolated Run On Different Port

This is specific to Azure Functions Dotnet Isolated mode but it is applicable to normal function as well.

Normally when there is only single function app, then there is no problem with default port settings of 7071. As no of function apps grow and required some integration between them, at that point it is required to run multiple function app and so different port settings required.

There is one settings in local.settings.json for "LocalHttpPort" but it is not working at the time of writing this article. There is bug registered so wait till it get resolved. By that time following settings can be useful.

Environment

  • Visual Studio 2022
  • .NET 6
  • Azure Functions v4
  • Command line

There are two solution

Pre-requisite

Install Azure Functions Core Tools. Download Location

Solution 1

This one is simple but required to run from command line.

  • Open the terminal and probably in Admin mode if there is some firewall settings.
  • Go to location at function app located. For example in my case it is located at image.png

  • Then run following command. func start --port <> image.png

  • It will run function app on 7073 port. image.png

Solution 2

In this solution we try to integrate in Visual Studio. Please take a note that, visual studio version in VS 2022.

  1. Go to Properties of Project.
  2. Then go to Debug -> General.
  3. Click on Open Debug Launch Profiles UI image.png
  4. In that Add new profile of type of "Executable" and following settings.
    • Executable : func
    • Command line arguments: start --port 7074 image.png
  5. Once done go to profile selection while project. lkmsG3IoAQ.gif

Solution 3

This is also related to Visual Studio 2022.

  1. In project structure , look for properties directory.
  2. That directory normally contains two files serviceDependencies.json and serviceDependencies.local.json.
  3. Add or update file launch settings.json. It will look something like this.
    {
    "profiles": {
     "FunctionAppPort": {
       "commandName": "Project"
     },
     "Port 7074 Configuration": {
       "commandName": "Executable",
       "executablePath": "func",
       "commandLineArgs": "start --port 7074"
     }
    }
    }
    
  4. Now same as Solution 2. Select specific profile to run.

Hope this helps.

Update 25-04-2022

As per the recent changes, Now it is respecting the configuration in local.settings.json which is not working earlier for isolated mode.

In local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
  },
  "Host": {
    "LocalHttpPort": 7073
  }
}