从.Net调用AWS步骤函数

时间:2018-05-27 01:03:44

标签: c# .net amazon-web-services aws-lambda aws-step-functions

我在循环中从lambda函数调用step函数。但是我收到了ExecutionAlreadyExistsException。我在这里做错了什么?

[Fact]
    public async void ActualSchedulingEngineStepFunctionCallTest()
    {
      var amazonStepFunctionsConfig = new AmazonStepFunctionsConfig { RegionEndpoint = RegionEndpoint.USWest2 };
      using (var amazonStepFunctionsClient = new AmazonStepFunctionsClient(awsAccessKeyId, awsSecretAccessKey, amazonStepFunctionsConfig))
      {
        var input = new Input
        {
          ID = "24232323232323232",
          Status = 1,
          Type = "Interim"
        };
        var jsonData1 = JsonConvert.SerializeObject(input);
        var startExecutionRequest = new StartExecutionRequest
        {
          Input = jsonData1,
          Name = "SchedulingEngine",
          StateMachineArn = "arn:aws:states:us-west-2:<SomeNumber>:stateMachine:SchedulingEngine"
        };
        var taskStartExecutionResponse = await amazonStepFunctionsClient.StartExecutionAsync(startExecutionRequest);
        Assert.Equal(HttpStatusCode.OK, taskStartExecutionResponse.HttpStatusCode);
      }
    }

堆栈跟踪:

Amazon.StepFunctions.Model.ExecutionAlreadyExistsException : Execution Already Exists: 'arn:aws:states:us-west-2:<SomeNumber>:execution:SchedulingEngine:SchedulingEngine'
---- Amazon.Runtime.Internal.HttpErrorResponseException : Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

2 个答案:

答案 0 :(得分:0)

更改名称

Name = "SchedulingEngine" <----- It should be unique for each execution

答案 1 :(得分:0)

删除“ name”参数,如果您需要频繁执行状态机,则不需要