简体   繁体   English

有没有办法阻止持久 azure function 的启动?

[英]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.

相关问题 Azure 耐用 function 崩溃了 - Azure Durable function is crashing out Python Azure 计时器 Function 带耐用实体 - Python Azure Timer Function with Durable Entity 并行运行 Azure 耐用 Function 的问题 - Problem Running Azure Durable Function in parallel 等待 azure function 持久编排完成 - Waiting for an azure function durable orchestration to complete Azure 耐用 Function 可以运行多长时间? - How long can an Azure Durable Function run for? Azure Function 长期和应用服务计划,持久 function - Azure Function long duration and App Service Plan, Durable function Azure 持久 function 多个版本的部署选项 function 应用程序 - Azure durable function deployment options for multiple versions of a function app 当 function 应用程序链接到 static web 应用程序时,如何获取 Azure 持久功能的状态? - How to get status of Azure durable functions when the function app is linked to a static web application? 持久 Function 异常:“无法找到用于此绑定的 Azure 存储连接字符串。” - Durable Function exception: "Unable to find an Azure Storage connection string to use for this binding." “未找到存储连接字符串。” 当试图从 azure 功能核心工具中列出持久的 function 实例时 - 'No storage connection string found.' when trying to list durable function instances from azure functions core tools
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM