Azure耐用功能错误“当前未注册任何活动功能!”

时间:2019-03-08 03:40:46

标签: c# azure azure-functions azure-functions-runtime azure-function-async

完整消息:

Function 'Function1 (Orchestrator)' failed with an error. 
Reason: System.ArgumentException: 
The function 'Function1_GetData' doesn't exist, 
is disabled, or is not an activity function. 
Additional info: No activity functions are currently registered!
[FunctionName("Function1")]
    public static async Task<List<string>> RunOrchestrator([OrchestrationTrigger] DurableOrchestrationContext context) {
        var outputs = new List<string>();

        using (var efContext = new DbContext()) {
            foreach (var s in efContext.Table) {
                var x= await context.CallActivityAsync<bool>("Function2_GetSummonerChanges", s.Id);
                outputs.Add(x.ToString());
            }
        }
        context.ContinueAsNew(null);
        return outputs;
    }

[FunctionName("Function1_GetData")]
    public static bool GetData(long Id) {
        return true;
    }

2 个答案:

答案 0 :(得分:0)

您没有活动功能“ Function2_GetSummonerChanges”的定义

可能是

[FunctionName("Function2_GetSummonerChanges")]
public static int MyActivityFunction([ActivityTrigger] int id, ILogger log)
{
   // your logic
}

请看以下示例,并链接以获取有关持久功能构建块的更多信息

https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-create-first-csharp

using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace FunctionApp28
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task<List<string>> RunOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var outputs = new List<string>();

            // Replace "hello" with the name of your Durable Activity Function.
            outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "Tokyo"));
            outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "Seattle"));
            outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "London"));

            // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
            return outputs;
        }

        [FunctionName("Function1_Hello")]
        public static string SayHello([ActivityTrigger] string name, ILogger log)
        {
            log.LogInformation($"Saying hello to {name}.");
            return $"Hello {name}!";
        }

        [FunctionName("Function1_HttpStart")]
        public static async Task<HttpResponseMessage> HttpStart(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
            [OrchestrationClient]DurableOrchestrationClient starter,
            ILogger log)
        {
            // Function input comes from the request content.
            string instanceId = await starter.StartNewAsync("Function1", null);

            log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

            return starter.CreateCheckStatusResponse(req, instanceId);
        }
    }
}

答案 1 :(得分:0)

就我而言,这是因为我错过了在活动类中添加触发器类型

public async Task Run(
          [ActivityTrigger])