[英]Is there a way to prevent start of a durable azure function?
I have an Azure Durable function (.NET 6) triggered with httpTrigger, I'm trying to prevent start of the function based on the parameters received in the http request.我有一个用 httpTrigger 触发的 Azure Durable function (.NET 6),我试图根据 http 请求中收到的参数阻止 function 的启动。
The code I tried so far:到目前为止我尝试过的代码:
[FunctionName(nameof(StartOrchestrator))]
public async Task<HttpResponseMessage> StartOrchestrator(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage req,
[DurableClient] IDurableOrchestrationClient starter)
{
var stringContent = await req.Content.ReadAsStringAsync();
var parameter = GetParam(stringContent);
if (string.IsNullOrEmpty(filter.MyParam))
{
//Here I want to prevent start of the orchestration with a 400 bad request error
return req.CreateErrorResponse(HttpStatusCode.BadRequest, "Request doesn't contains MyParam");
}
var instanceId = await starter.StartNewAsync(nameof(RunOrchestrator), parameter);
return starter.CreateCheckStatusResponse(req, instanceId);
}
The result I'm getting:我得到的结果:
Is there a way to do what I'm trying to?有没有办法做我想做的事?
It should be a semaphore issue, two threads are created right here and azure functions doesn't support synchronouse operations so this is where the 500 is coming from.这应该是一个信号量问题,两个线程就在这里创建,azure 函数不支持同步操作,所以这就是 500 的来源。 The solution is to set the variable FUNCTIONS_V2_COMPATIBILITY_MODE
解决方案是设置变量 FUNCTIONS_V2_COMPATIBILITY_MODE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.