Azure API Management: storing Login event to table storage - azure

Update
The link below is used to request token and refresh token depending on a field in the body:
http://example.com/token
1 Request a token
A field in the body: grant_type:password
Steps:
1 When the request arrives, APIM forwards it to 3rd party
2 Once APIM receives the reponse from 3rd party, it returns the result to its client.
We want to log data (url, response status code) for this url to Table Storage. Requet for the same url is not logged below:
2 Refresh the token
A field in the body: grant_type:refresh_token
Application Insight is used with APIM, I wonder if Table Storage is the best tool.
Is there built-in UI that is available for viewing data stored in Table Storage
Any information or link or code sample would be appreciated.
C#
VS 2017

APIM has a few ways to send data out of request processing pipeline:
send-request/send-one-way-request allows you to send an HTTP request, you're in charge of constructing request in HTTP terms: method, URL, headers, body.
log-to-eventhub allows you to send a message to EH. You can specify C# expression that produces message payload.
AppInsights integration will allow you to record client request, backend request, backend response, and client response for each request processed by APIM. You can configure it to log extra headers and part of body.

Related

what is the code for getting auth code from azure in IBM BPM

I am trying to create rest request using Call Multipart form data REST API service in REST API toolkit. It requires apiURL, HTTPHEADER, PARAMETERtoPOST, httpMethod (using GET). I defined all the parameters(client id, client secret, response type (code), scope and response mode (query)) and httpheader - > Content -Type is application/x-www-form-urlencoded.
But in the response message I dont get the authcode even though when I create whole URL directly including parameters , I get the authcode but without Redirect URI. If I include redirect uri, it shows me that URI is not configured even though system admin for that showed me its configured.
So am I missing any parameters or anything else?

How to pass Body Parameters(format) when calling a POST request with Content-Type as form-data in Azure Data Factory

I am trying to call API endpoint as a POST and Content-Type as from-data using azure data factory web activity. Tried different way of passing Body parameters but it failed.
Here is the Postman Request.
Here is the Azure Data Factory Web Activity configurations.(use the body as a json and tried different combinations but all didn't work)
And above is the error message.
Any help would be highly appreciated.
Since your request is seen successfully executing from postman, try copying the entire body from that and use in web activity.
The format for passing body for a POST request from a web activity is shown here.
Also make sure you have entered valid “url–Target endpoint and path”. This is usually seen as Activity requires Public end point but you may have used Private vnet where this is not allowed. Web Activity is supported for invoking URLs that are hosted in a private virtual network as well by leveraging self-hosted integration runtime. The integration runtime should have a line of sight to the URL endpoint.
Note: The activity will timeout at 1 minute with an error if it does not receive a response from the endpoint.
Further going through some similar scenarios it is learnt that;
Mostly the header is passed as string in WebActivity whereas Postman
it is integer/long
In case your API tries redirecting, it seems that the web activity
in Azure Data Factory does not currently support following
redirects, meanwhile Postman and other tools and libraries usually
follow redirects by default or include a option for handling them.
Checkout the supported authentication types in the web activity. If you are trying to authorize your from, try set the following.
URL: https://login.microsoftonline.com/<<tenantid>>/oauth2/token
Headers: Content-Type - "application/x-www-form-urlencoded"
Body: grant_type=client_credentials&client_id=<<clientid>>f&client_secret=<<secret>>&resource=https%3A%2F%2Fmicrosoft.onmicrosoft.com%2F<<resourceId>>
Error code: 2108:
Message: Error calling the endpoint '%url;'. Response status code: '%code;'
Cause: The request failed due to an underlying issue such as network connectivity, a DNS failure, a server certificate validation, or a timeout.
Workaround: Make the API call using Powershell, and call that Powershell script from within Data Factory.

POST data on Azure Event hub is failing

This is regarding Azure Event hub and I am trying to send data using a POST api call from POSTMAN to my Event hub.
Steps I followed:
Created Event Hub,
Generated SAS send token,
Created Consumer group
Now in postman I am struggling to format the correct headers:
request I send:
POST: https://testeventhu.servicebus.windows.net/myhub
2 headers :
Content-Type : application/atom+xml;type=entry;charset=utf-8
Authorization: SharedAccessSignature sig=kjheh/f6SqR8dIW2nRpGUCHuhdshss2KoCKo7Q6ozmY=&se=1571140739&skn=saspolicy&sr=https://testeventhu.servicebus.windows.net/myhub
and I get the error as 401 MalformedToken: Failed to parse simple web token
What wrong am I doing in here?the refrence used is from https://learn.microsoft.com/en-us/rest/api/eventhub/Send-event?redirectedfrom=MSDN
Thanks in advance
Please follow my steps as below:
1.After you create your eventhub namesapce and eventhub instance in azure portal -> in azure portal, nav to your eventhub namespace -> Shared access policies, click "Add" button to create a sas policy(here, I just select the Send privilege for sending purpose). The screenshot as below:
2.Generate sas token, I create the sas token via powershell as per this link. Here is my powershell code and the returned sas token:
3.In postman:
The request url should like this, remember add messages at the end: https://your_eventhub_namespace.servicebus.windows.net/your_eventhub_instance/messages
The headers:
Authorization : the sas token from step 2
Content-Type: application/atom+xml;type=entry;charset=utf-8
Host(optional): your-eventhub-namespace.servicebus.windows.net
the screenshot as below, you can see the returned status code is 201 created:
And if you don't know how to set the message body, you can see my message in body in postman:
Please feel free to let me know if you still have any issues.

The Format of Body for a POST request in Web Activity in Azure Data Factory

I have created a web activity in azure data factory pipeline which have only one header and I have to pass body for a POST request. I have tried passing body as JSON and as String also but the request failed with "Invalid Query". Can anyone please tell me how can I send a POST request from azure data pipeline with additional header and body. I have multiple key value pairs to pass to body.Check the Screenshot of web activity
Please try this. First, add one more header with Name of Content-Type and value of application/x-www-form-urlencoded
Then change the Body to:
grant_type=password&username={username}&password={password}&scope=customer-api

How to configure Azure AD Oauth2 token endpoint for params vs. in-body?

I'm using Azure AD to provide Oauth2 auth for an API. Setup & config seemed to work fine for me, but a partner pointed out that the Oauth2 token endpoint doesn't like inline parameters -- it wants params passed in the HTTP body instead.
Ex: this call returns AADSTS90014: The request body must contain the following parameter: 'grant_type':
https://login.microsoftonline.com/my tennant/oauth2/token?grant_type=client_credentials&client_id=theclientid&client_secret=thesecret&code=AUTHORIZATION_CODE'
But a post w/ the same params in the body as form data works just fine. I believe Oauth is supposed to supposed to support the parameterized call (as shown in google documentation).
Is there somewhere in Azure to configure the Oauth2 endpoint to accept token parameters as post params vs. sending in the form body?
he request body must contain the following parameter: 'grant_type':
Based on the response I would say you are setting the content-type header wrongly.
If you are posting this request : https://login.microsoftonline.com/my tennant/oauth2/token?grant_type=client_credentials&client_id=theclientid&client_secret=thesecret&code=AUTHORIZATION_CODE' ensure that you are setting the content-type as application/x-www-form-urlencoded.
If you are the parameters in the body set the content-type as application/json

Resources