简体   繁体   English

我可以从Azure函数调用rest API吗?

[英]Can I call a rest API from an Azure function?

I have a CosmosDB Document API with two document collections. 我有一个带有两个文档集的CosmosDB Document API。 I need everytime a document is inserted in one of the collections to run a custom API call using a property of the document. 每次在其中一个集合中插入文档时,我都需要使用文档的属性来运行自定义API调用。 Can I use Azure Function Apps to do that? 我可以使用Azure功能应用程序来做到这一点吗? If not is there any way to accomplish that? 如果没有,有没有办法实现这一目标?

Yes, you can call HTTP REST API from a C# Azure Function. 是的,您可以从C#Azure功能调用HTTP REST API。 Just use the same HttpClient that you would use from other type of application. 只需使用您在其他类型的应用程序中使用的相同HttpClient You can make your client static so that it gets reused between the calls. 您可以使您的客户端保持静态,以便在调用之间重用它。

The trigger of your function will likely be Cosmos DB Change Feed trigger . 您的功能触发器可能是Cosmos DB Change Feed触发器

That you are looking for is the change feed feature. 您正在寻找的是更改Feed功能。 As you can read in the highlighted link one of the things you can do with this is 正如您可以在突出显示的链接中阅读的一样,您可以使用此功能

Triggering a notification or a call to an API when a document is inserted or modified. 插入或修改文档时触发通知或API调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM