1

Upto now i used only one azure function http trigger do functionality. However, i got a new requirement to call a one azure function app F1 in another azure function app F2. I want to use the function app F1 using dll and function.json file in azure function app F2.

Function.json of F1:

 {
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.24",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "httpTrigger",
      "methods": [
        "get",
        "post"
      ],
      "authLevel": "anonymous",
      "name": "fnRequest"
    }
  ],
  "disabled": false,
  "scriptFile": "**Function F1 dll path**",
  "entryPoint": "FunctionApp1.Function1.Run"
}

Function2:

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using FunctionApp1;

namespace FunctionApp2
{
    public static class Function2
    {
        [FunctionName("Function2")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ExecutionContext executionContext)
        {
            return await Function1.Run(req, executionContext);           
        }
    }
}

could anyone please help me out for the procedure to call.

Thanks in advance!.

prasanthi
  • 562
  • 1
  • 9
  • 25
  • could you explain a little bit about what you are trying to do? Instead of calling another function, I would execute the code the function 2 would execute in function 1. Another option would be to put a message on a service bus or storage queue for the 2nd function to pick up – ejwill Mar 02 '21 at 01:23
  • @ejwill, thank you for the reply, yes i can use service bus or storage queue. the function app F2 is debugger solution for the function app F1. so,i would like to call the function app F1 from function app F2. – prasanthi Mar 02 '21 at 05:33
  • I don't understand what you mean by a debugger solution. You can run your function locally if you want to debug it. – ejwill Mar 02 '21 at 15:15

1 Answers1

2

Since the function1 and function2 are in different apps and the function1 is disabled, then you need to add a project reference of FunctionApp1:

enter image description here

enter image description here

Then your function2 should be able to call function1 using Function1.Run(req, executionContext).

By the way, in general, we use the function url to call the azure function instead of introducing another project.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27