如何在 C# 中以编程方式检查队列触发函数的状态?

发布于 2025-01-13 11:04:16 字数 913 浏览 3 评论 0原文

我有两个azure函数,一个是HttpTrigger,一个是QueueTrigger。 http 触发器的目的是从某个服务获取一些数据并将其放入 blob 存储中。队列触发器的目的是从 Blob 存储中获取数据并将其保存在本地数据库中。当http触发器完成作业时,队列触发器将自动触发。

我想知道如何知道队列函数何时以编程方式完成? 所以,我有一些服务正在调用这个 http 触发函数:

        public async Task<HttpResponseMessage> CallHttpAzureFunction(int someParameter)
        {
            var client = new HttpClient();

            var azureFunctionsPath = "someRandomPath";
            var url = $"{azureFunctionsPath}/{AzureFunctionConstant.NameOfFunction}";
            var request = "not important"            

            var response await client.PostAsync(url, new StringContent(JsonConvert.SerializeObject(request)));

            if (response.Result.IsSuccessStatusCode)
            {
                //Check the status of queue function, if it is finished, call the database to get that data
            }
        }

I have two azure functions, one is HttpTrigger, one is QueueTrigger. The purpose of the http trigger is to get some data from some service and put it in blob storage. The purpose of queue trigger is to get that data from blob storage and save it in local database. When http trigger finish the job, the queue trigger is triggered automatically.

I am wondering how can I know when the queue function is finished programmatically?
So, I have some service which is calling this http trigger function:

        public async Task<HttpResponseMessage> CallHttpAzureFunction(int someParameter)
        {
            var client = new HttpClient();

            var azureFunctionsPath = "someRandomPath";
            var url = 
quot;{azureFunctionsPath}/{AzureFunctionConstant.NameOfFunction}";
            var request = "not important"            

            var response await client.PostAsync(url, new StringContent(JsonConvert.SerializeObject(request)));

            if (response.Result.IsSuccessStatusCode)
            {
                //Check the status of queue function, if it is finished, call the database to get that data
            }
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若言繁花未落 2025-01-20 11:04:16

目前,您无法获取 azure 函数的状态,但如果它是持久函数,您可以将客户端重定向到客户端轮询以了解操作何时完成的状态端点。

参考:

  1. 如何检查函数的状态
  2. 持久函数概述
  3. 如何查看运行状态并停止Durable功能

Currently, you can't get the status of the azure function but if it is a durable function you can redirect the client to a status endpoint that the client polls to learn when the operation is finished.

REFERENCES:

  1. How to check the status of a Function
  2. Durable Functions Overview
  3. How to check running status and stop Durable function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文