6

I have this function


    public class Functions
    {
        public Functions()
        {

        }

        [FunctionName("httptriggertest")]
        public async Task<IActionResult> HttpTriggerTest([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "httptriggertest")] HttpRequest req,
            ILogger log)
        {
            log.Log(LogLevel.Information, "Received request request");

            return new OkObjectResult("HttpTriggerTest");
        }
    }

And run it by this:

    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebJobs(b =>
                {
                    b.AddAzureStorageCoreServices()
                        .AddAzureStorage()
                        .AddHttp();
                })
                .ConfigureLogging((context, b) =>
                {
                    b.SetMinimumLevel(LogLevel.Debug);
                    b.AddConsole();
                })
                .ConfigureAppConfiguration(b =>
                {
                    b.AddCommandLine(args);
                })
                .UseConsoleLifetime();
    }

when i run dotnet run it starts fine (the function is discovered by the runtime)

info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
      Starting JobHost
info: Host.Startup[0]
      Found the following functions:
      Functions.Functions.HttpTriggerTest

info: Host.Startup[0]
      Job host started
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /home/mslot/git/sut_test/job1
dbug: Microsoft.Extensions.Hosting.Internal.Host[2]
      Hosting started
^Cinfo: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
dbug: Microsoft.Extensions.Hosting.Internal.Host[3]
      Hosting stopping
info: Microsoft.Azure.WebJobs.Hosting.JobHostService[0]
      Stopping JobHost
info: Host.Startup[0]
      Stopping the listener 'Microsoft.Azure.WebJobs.Extensions.Http.HttpTriggerAttributeBindingProvider+HttpTriggerBinding+NullListener' for function 'httptriggertest'
info: Host.Startup[0]
      Stopped the listener 'Microsoft.Azure.WebJobs.Extensions.Http.HttpTriggerAttributeBindingProvider+HttpTriggerBinding+NullListener' for function 'httptriggertest'
info: Host.Startup[0]
      Job host stopped
dbug: Microsoft.Extensions.Hosting.Internal.Host[4]
      Hosting stopped

But what is the URL for this? Is this even possible on localhost to call the http endpoint? I have tried all sorts of variations of http://localhost/

mslot
  • 4,959
  • 9
  • 44
  • 76

1 Answers1

0

Right click your Azure functions project. Go to properties. Select Debug. Provide the below command under Application Arguments.

host start --port 7073 --pause-on-error

You can provide any port number you prefer. Save the changes. Run your function app again. It will open a console window. After few minutes it will display all your localhost endpoint URLs there.

Sanushi Salgado
  • 1,195
  • 1
  • 11
  • 18