I am having an Http triggered azure function which I am able to debug successfully using Postman by calling the api in postman and getting the desired response. Now I am trying to debug by calling the api from a separate method and that I am doing by calling the api in the main function something like this:
Azure Function:
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
var requestBody = await new StreamReader(req.Body).ReadToEndAsync();
return new OkObjectResult("Test");
}
}
class Program
{
static async Task Main(string[] args)
{
HttpClient client = new HttpClient();
var requestUri = new Uri("http://localhost:7071/api/Function1");
var rec = "Test:test";
var response = await client.PostAsJsonAsync(requestUri, rec);
}}
When I run I get an error in the last line saying "target machine actively refused the connection". The url is same which I am passing in postman and when I do from postman, it hits my function method. What wrong am I doing here??
Note: I have not yet published my function as I am debugging locally now
question from:
https://stackoverflow.com/questions/65860682/way-of-debugging-in-azure-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…