简体   繁体   中英

Can I call a rest API from an Azure function?

I have a CosmosDB Document API with two document collections. I need everytime a document is inserted in one of the collections to run a custom API call using a property of the document. Can I use Azure Function Apps to do that? If not is there any way to accomplish that?

Yes, you can call HTTP REST API from a C# Azure Function. Just use the same HttpClient that you would use from other type of application. 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 .

That you are looking for is the change feed feature. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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