3

I've implemented an Azure durable function which as you know contains my Orchestration, Orchestrator and Activities.
the point is one of my activities is implemented in another assembly and I referenced it as a nuget package.
Now the problem is when I'm running my solution in Visual Studio all the Azure Functions loading by AzureFunctionsTools but this activity which located in the nuget package is not listed and I'm facing the below error message:

Error: 'MyExternalActivity' doesn't exist, is disabled, or is not an activity function. Additional info: The following are the known activity functions: 'MyLocalActivity'.

And here is my MyExternalActivity definition in the nuget project:

[FunctionName(FunctionName)]
public async Task<object> Run([ActivityTrigger] DurableActivityContextBase context) 
{
...
}

And here it is my Orchestrator class:

[FunctionName(FunctionName)]
public static async Task RunOrchestrator([OrchestrationTrigger] DurableOrchestrationContextBase context, ILogger log)
 {
    ...
    await context.CallActivityAsync<object>("MyLocalActivity", parameters); // Successfull; code is in this solution
    ...   
    ...
    await context.CallActivityAsync<object>("MyExternalActivity" , parameters); // Error; Referenced by nuget package
    ...
}

Note: I tried to remove the reference and add the nuget code project to the same solution and reference through the project directly, But same error happening

Mohammad Nikravesh
  • 947
  • 1
  • 8
  • 27

1 Answers1

6

The reason you are having this issue is because calling a different function is not the same as calling a method in a different project or nuget package. They are completely seperate entities so adding a reference will not cause the activity function to be included.

The correct way to implement this is to have both of the functions defined in a single project. You can absolutely have the function definition be a shell that then calls out to code in a nuget package.

[FunctionName(FunctionName)]
public async Task<object> Run([ActivityTrigger] DurableActivityContextBase context) 
{
    MethodFromNugetPackage(context);
}

If you want to have the functions in different projects, there are a couple options:

1) Have multiple Function services in Azure.

2) Deploy the code with "Remove additional files in destination" turned off. This assumes that you are deploying from Visual Studio, so if you are using a different deployement method you will need to find and adjust the equivelent setting. To be clear this is not recommended as you could run into issues that are difficult to track down, but it should work. enter image description here

PerfectlyPanda
  • 3,271
  • 1
  • 6
  • 17
  • Having both functions in one project could be a solution, But It's not mine! I clearly mentioned I have two functions in two different projects. and I want to find a solution to this architecture. Thank you by the way. – Mohammad Nikravesh May 02 '19 at 01:17
  • 1
    I've updated my answer with a couple ways to keep your functions in different projects. Including your function definitions in a nuget package will not work. – PerfectlyPanda May 02 '19 at 13:01