Azure API Management is an Azure service to create consistent API gateways for secure, scalable access for back-end applications and services.
Azure API Management consists of 3 main components
- Azure Portal for administration
- Developer Portal for API documentation
Each API inside Azure API Management contains a reference to the back-end service that implements the API and its operations.
Let us start by creating the Azure API Management resource –
Login to Azure Portal
https://portal.azure.com/
Search for API Management
Provide the appropriate details. (Here we have selected the – Developer tier)
After validation is passed, review and click on Create.
It will take around 30 minutes for the deployment to be finished
After the deployment is successful, we can navigate to it and can find the Gateway URL and Developer portal URL as shown below.
Here we will start with a Blank API.
Specify the display name, name and for Web service URL the URL of Dynamics 365 Web API
Click on +Add operation to add a new operation to the API.
Specify the URL as shown below to fetch all the contacts from Dynamics 365.
The URL of the operation
Right now we will get the 401 error as expected as we have not passed the token expected by the Web API.
Now for the token part for calling the Dynamics 365 API, register the Application in Azure AD, create a new Application User, and assign appropriate security roles to it.
https://docs.microsoft.com/en-us/powerapps/developer/data-platform/authenticate-oauth#connect-as-an-app
Here we would be defining send-request policy, to generate the Token and pass it in the Authorization header to the Dynamis 365 Web API request.
Select the GET operation, navigate to the Design tab and open the policy code editor for inbound processing
Add the send-request and set-header policy to generate and set the bearerToken
Specify the endpoint URL of OAuth token, client id, client secret of the application registered.
"copy code from the end of the post"
Save the change and let us test the API.
We can see the results as expected.
The other things that can be done are to associate the API with Products, specify Subscription, Security, enable Application Insights, Azure Monitor etc.
Specify policies –
https://docs.microsoft.com/en-us/azure/api-management/api-management-policies
References –
https://transform365.blog/2020/03/29/azure-api-management-and-dynamics-365-web-api/
https://app.pluralsight.com/library/courses/microsoft-azure-developer-implement-api-management/table-of-contents
Hope it helps..
<policies> <inbound> <base /> <send-request mode="new" response-variable-name="bearerToken" timeout="20" ignore-error="true"> <set-url>https://login.microsoftonline.com/89a735bf-2d85-4a5b-a74a-59656af50f2e/oauth2/token</set-url> <set-method>POST</set-method> <set-header name="Content-Type" exists-action="override"> <value>application/x-www-form-urlencoded</value> </set-header> <set-body>@{ return "client_id=510b66c9-4841-4d3d-8e95-150779adcb3e&resource=https://gcrm.crm.dynamics.com&client_secret=t~6DU7Ma4GZjh.M0Xf7eCizy.E~ME4zy_3&grant_type=client_credentials"; }</set-body> </send-request> <set-header name="Authorization" exists-action="override"> <value> @("Bearer " + (String)((IResponse)context.Variables["bearerToken"]).Body.As<JObject>()["access_token"])</value> </set-header> </inbound> <backend> <base /> </backend> <outbound> <base /> </outbound> <on-error> <base /> </on-error>
</policies>
-
Unable to retrieve attribute=businessunitid for entityLogicalName=systemuser exception while creating Application User in Dynamics 365
by Nishant Rana
January 20, 2021
-
Manage Dynamics 365 Web API with Azure API Management
by Nishant Rana
January 19, 2021
Azure API Management is an Azure service to create consistent API gateways …
Continue reading “Manage Dynamics 365 Web API with Azure API Management”
-
Execute Privilege Name (ExecutePrivilegeName) property of Custom API in Dynamics 365 / Microsoft Dataverse
by Nishant Rana
January 14, 2021
-
Use Custom API to create custom messages in Dynamics 365
by Nishant Rana
January 13, 2021
-
Improved search experience in Dynamics 365 / PowerApps
by Nishant Rana
January 12, 2021
- Migration of Personal views/charts/dashboards with sharing information
by Nishant Rana
January 7, 2021
Originally posted on
Phani Rajasekhar:
In my previous blog I explained the issues that I faced while POA entity migration. Here…
-
Sample Code – Dynamics 365 Web API / Organization Service
by Nishant Rana
January 6, 2021
Use CrmServiceClient to execute web request against Dynamics 365 Web API – …
Continue reading “Sample Code – Dynamics 365 Web API / Organization Service”
-
Dynamics 365 Sales mobile app (preview)
by Nishant Rana
January 5, 2021
The new Dynamics 365 Sales mobile app (preview), has been introduced specifically …
Continue reading “Dynamics 365 Sales mobile app (preview)”
-
Application User Form missing in Dynamics 365
by Nishant Rana
December 24, 2020
Recently while trying to create a new application user, we could not …
Continue reading “Application User Form missing in Dynamics 365”
- D365: “The user is not a member of the organization” error while connecting to CE
by Nishant Rana
December 23, 2020
Originally posted on
Ajit Patra:
Recently, we were working on connecting to CE to do some CRUD operation using Azure function.…
-
Part 6: Data Integration – Return of the Best Practices
by Nishant Rana
December 23, 2020
Originally posted on
Matthew Webb’s Dynamics 365 Blog:
Recap Best Practices: Part 2 Welcome back! My previous blog discussed the use of Staging Databases as…
-
Historical Data Migration – Created On and Modified On in Dynamics 365
by Nishant Rana
December 22, 2020
-
Azure Data Lake Storage Component in KingswaySoft – SSIS
by Nishant Rana
December 22, 2020
- IP ranges for Dynamics 365
by Nishant Rana
December 21, 2020
Originally posted on
Biplab Singha’s blog:
IP whitelisting (Range) for Dynamics 365. In one of our recent project we need to call…
-
Setup a free trial of Dynamics 365 Marketing
by Nishant Rana
December 21, 2020
If we already have a Microsoft 365 / Dynamics 365 tenant, we …
Continue reading “Setup a free trial of Dynamics 365 Marketing”
- Wrestling With Email Address Limitations
by Nishant Rana
December 17, 2020
Originally posted on
That CRM Blog:
Dynamics CRM has been around for a while (about 13 years) and, as is the way…
-
Consume Dynamics 365 Web API using MSAL.NET
by Nishant Rana
December 17, 2020
Sharing a sample code to consume Dynamics 365 Web API using MSAL.NET …
Continue reading “Consume Dynamics 365 Web API using MSAL.NET”
- Updating Entity Reference Power Automate vs Plugin
by Nishant Rana
December 16, 2020
Originally posted on
Vrushali’s Techno Blog:
Recently I worked on a project where not a single line of code was allowed. It…
-
Fixed – 401 Unauthorized error while calling Dynamics 365 Web API
by Nishant Rana
December 16, 2020
-
Read Secret from Azure Key Vault using Key Vault Rest API through Postman
by Nishant Rana
December 15, 2020
-
Check user’s access to a record – upcoming feature in Dynamics 365
by Nishant Rana
December 13, 2020
-
How to trigger Power Automate flows from Model-Driven Power App Business Process Flows (and get a response!)
by Nishant Rana
December 12, 2020
Originally posted on
ReadyXRM:
I was working on a project the other day and the requirement was for a user…
-
Fixed – Repairing disk errors. This might take over an hour to complete – Windows 10
by Nishant Rana
December 12, 2020
-
Power Platform for Admins connector (preview) in Power Automate
by Nishant Rana
December 12, 2020
The Power Platform for Admins connector (preview) let’s us perform following Actions …
Continue reading “Power Platform for Admins connector (preview) in Power Automate”
-
Personalize the Experience with Voice of the Customer – Part 2
by Nishant Rana
December 11, 2020
Originally posted on
Virendra Agrawal’s Blog:
Previously (Part 1), we talked about how we could include that piped data in our survey…
-
5000 records limit of Fetch XML Query – List records action of Common Data Service (current environment) connector in Power Automate
by Nishant Rana
December 11, 2020
-
Posts on Azure Data Lake
by Nishant Rana
December 10, 2020
-
Comparing the three main ways to get Dynamics 365 data into Power BI
by Nishant Rana
December 10, 2020
Originally posted on
crm chart guy:
There are a few different ways to get your Dynamics 365 data into Power BI. Now…
-
Use query acceleration to retrieve data from Azure Data Lake Storage
by Nishant Rana
December 8, 2020
-
Fixed – AADSTS7000218: The request body must contain the following parameter: ‘client_assertion’ or ‘client_secret
by Nishant Rana
December 1, 2020
- Working with large CDS datasets in Power Automate Flows and Logic Apps
by Nishant Rana
December 1, 2020
Originally posted on
EVOLVED365:
During the last 12 months I have been busy working on projects and lost my way…
-
Fixed – AADSTS65001: The user or administrator has not consented to use the application with ID
by Nishant Rana
December 1, 2020