azure - 如何从另一个azure函数触发http azure函数

标签 azure azure-functions

根据 Azure Durable Function,我编写了一个 HTTP 触发器 azure 函数,该函数执行一系列操作(例如将文件添加到 blob 存储、列出它们、删除它们或通过协调器执行更多需要时间的任务)。 .

我想通过附加的 azure 函数检索此类需要任务的时间的状态,该函数根据协调器的作业 ID 返回“待处理”、“已完成”或“失败”。为此,我需要在主 HTTP 触发函数内发出请求以请求此类状态。

我已经尝试过:

它们显然都不能在本地工作,因为 Debug模式下的 Visual Studio Code 完全卡住。是否是由于授权问题或者无法在本地触发另一个azure功能?部署代码后它会起作用吗?

我已阅读 stackoverflow 中的建议文章和相关的 azure 函数文档,但没有一个提供完整的答案。

最佳答案

How to trigger a http azure function from another azure function

C#中,您可以使用httpClient进行调用,如下所示:

var r = await httpClient.GetAsync("http://localhost:7114/api/Function1");
var c = await r.Content.ReadAsStringAsync();
var response = req.CreateResponse(HttpStatusCode.OK);

enter image description here

两个函数的输出:

从另一个函数调用的函数(函数 1 应该开始执行,如下所示: enter image description here

然后,当我运行函数 2 时,这是函数 1 的日志:

enter image description here

更多信息您可以引用this .

对于 VS CODE 中的 python:

默认情况下,在 Visual Studio 中,不同的项目在不同的端口上运行,而在 VS 代码中使用相同的端口,您将收到此错误:

enter image description here

部署到门户: enter image description here

然后获取如下 URL:

enter image description here

为此,您需要首先将函数部署到 azure,然后获取 URL 并使其按如下方式工作:

u='https://rith34.azurewebsites.net/api/HttpTrigger1?code=jd5WmzFuRxdyTg=='

requests.post(u)

enter image description here

需求.txt:

enter image description here

门户中的输出:

检查已部署的功能监视器部分:

enter image description here

如需进一步引用类似example .

关于azure - 如何从另一个azure函数触发http azure函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76425849/

相关文章:

jquery - 如何在单个网页中使用多个 Application Insights

azure - 非常简单的 SQL 查询在带有小表的 azure sql 数据库上超时

azure - 如何通过 SSH 连接到 Azure Function Linux

python - Azure Functions (Python) blob 输出绑定(bind)。当名称只是输入消息的一部分时如何设置名称

javascript - 在 JavaScript Azure Function 代码中引用外部脚本

azure - 无法将对象添加到 Azure Function 的 settings.json

azure - 我似乎无法从 Azure Linux VM 连接到 Azure Database for MySQL 服务器

node.js - Azure Function 应用程序 key 经常更改

azure - JSON 对象作为 ARM 模板函数参数

Azure Functions v2 和 Google Auth