Georgia Kalyva
Georgia Kalyva

Reputation: 797

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?

Upvotes: 1

Views: 8274

Answers (2)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35124

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.

Upvotes: 3

Christos
Christos

Reputation: 53958

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.

Upvotes: 1

Related Questions