HTTP Rest API from Azure Cosmos DB User Defined Function (UDF) - azure

I am working with CosmosDB and fetching data, which has a few tokenized fields due to security. The obvious way to handle this is to make a query, get the data from CosmosDB and then de-tokenize it using a REST API.
But I am trying to check if there is a way where in we can use a UDF in Azure CosmosDB and make a REST API call from the UDF Javascript, which so far I am unable to do. If this is possible, I only call the query (with the UDF) and I get de-tokenized data back.
** The de-tokenize process has to happen through a REST API call to external party.
Any help or experience will be appreciated.
Thanks

This is not possible with a UDF or any server-side capability in Cosmos. The security implications for this is why it's not allowed/possible.
You'll need to read the data into your app, then make the REST call before passing down to the user.
Thanks.

Related

Get Records from Salesforce using Azure Logic Apps

I am trying to use Azure Logic Apps to read data from one of the Salesforce objects which has huge number of records. The Salesforce connector fetches the record and returns the pagination link as #odata.nextLink. But when I try to use a JSON parser to read the value it’s coming as null.
I tried to access the nextlink in a browser but it requires authentication. What authentication do we pass here ?
I would like to use an until action to iterate till I get a next link . So how do I check the condition for the until loop ?
nextLink doesn't look like core Salesforce thing, it might be the OData connector preprocessing the results for you. You'd have to consult the documentation for the connector (if any).
Salesforce's REST API will return field with nextRecordsUrl if there's next page of results, you'd call that in loop until the field disappears. You'd call it like any other REST API resource available after login, by passing Authorization: Bearer <sessionId also known as accessToken here>. Again - probably the connector abstracts this away from you. Don't think you can send headers like that in browser, you'd need curl, Postman, SoapUI or similar http client.
If you don't get better answer and documentation is scarce - consider using raw REST API. Or Azure Data Factory has an almost-decent Salesforce connector?
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm

How to call event Analytics DialogFlow by nodejs

I'm using dialogflow v2 using npm https://github.com/googleapis/nodejs-dialogflow.
Then I have a task to call API to get the number of messages in analytics.
https://dialogflow.cloud.google.com/#/agent//analytics
use this API
https://api.dialogflow.com/api/interactions/analytics/messages?timeInterval=1.
So anyone can suggest to me how to call that API in dialogflow npm. I can not get
x-goog-access-token
x-goog-id-token
See https://developers.google.com/identity/protocols/oauth2 for more about generating the auth token for a REST request using a service account. But that isn't the problem.
The real issue is that you're trying to access an internal API, and your project likely isn't permitted to this API.
The library itself doesn't have access to that portion of the API as well, so even if you were permitted (and, I should emphasize, you're probably not), you would need to make the REST calls directly without a library.

How to dynamically pass MS Dynamics token to REST API setup in Azure Data Factory?

MS Dynamics 365 has exposed two REST APIs in order to get to the data. The first API is an URL that returns a token. I need to dynamically pass the token as header to the second REST API and pull the actual data. Can we use Logic Apps or Azure data factory to accomplish this? If yes, can you please provide the steps to accomplish this? Any help will be much appreciated. Thanks in advance.
Logic Apps has a native connector to the D365 Common Data Service, and it can be triggered using a REST call, so it could in effect replace the need for the native REST API, but it would not be my first choice because it will add some overhead (delay) to your round-trip depending on whether the Logic App has been used lately.

custom input & output fields for azure function

I am not sure if this is an option. I require it badly, and cannot find any references of it.
When integrating between an HTTP Triggered Azure Function within your Logic App flow, you are requested to pass a body object for the function to digest:
I am hoping for a way to customize the Request Body inputs, to make it have a strict template structure, in and out.
In:
Out:
(The function returns an Object)
Is there any way I can achieve this?
You could create a Logic Apps Custom Connector.
You can create one of these from a Postman collection or using an OpenAPI definition. You can get hold of the OpenAPI definition from the Function App.
With a custom connector, you have a bit more control over the request and response. This will allow the users of your connector to provide inputs when used in a Logic App and also receive tokens from the response. These can then be used in further Logic App steps.
Just hard coded it to the fields I require it using the Logic App syntax and it responds to satisfaction
#{body('function-name')?['property']}
Haven't tried the Custom Connector

Is it possible to make httprequest from Azure cosmos db?

I'm trying to learn Azure Cosmos Db. I've read the document.
As far as I see, we can create .Net/NodeJs/Java applications, and get/insert/update data in the Cosmos Db.
However, I'm not clear whether we can make a http request from JavaScript/JQuery/etc..
to fetch data:
does cosmos db provide only .net/java/nodejs/phyton, or we can make a request using any software language?
Thanks in advance.
Cosmos exposes a REST API, so you can access with anything capable of creating HTTP requests. Here’s the API documentation https://learn.microsoft.com/en-us/rest/api/documentdb/
I want to answer my question. I tried to make an http request from Azure Cosmos DB and I did.
There is only one crucial step that you need to create an auth code for each request. You can create the auth code by reading below page
https://learn.microsoft.com/en-us/rest/api/documentdb/access-control-on-documentdb-resources?redirectedfrom=MSDN
This is the detailed document for using Cosmos DB Rest API.
https://learn.microsoft.com/en-us/rest/api/documentdb/restful-interactions-with-documentdb-resources
I hope this would be helpful.

Resources