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>
Search this view capability on Grid in Dynamics 365 by Nishant Rana
March 8, 2021 Search this view capability which was added in the product with 2020 …
Continue reading “Search this view capability on Grid in Dynamics 365”
D365 Customer Service : Voice Channel by Nishant Rana
March 5, 2021 Originally posted on
Everything D365 :
Good customer service is taken for granted. To stand out, companies need exceptional customer service that…
Upload file to Azure Blob Storage using BlobClient class – C# by Nishant Rana
March 5, 2021
Scripting AzCopy for automated upload by Nishant Rana
March 4, 2021 Originally posted on
Tech Wizard :
Today we will discuss how we can use powershell & script the azcopy to upload the…
Open forms, views, and dashboards through URL in Dynamics 365 Mobile / Tablet App by Nishant Rana
March 4, 2021
Macros in Omnichannel and Customer Service Workspace – Dynamics 365 by Nishant Rana
March 3, 2021
Error – “Microsoft SQL: A network-related or instance-specific error occurred while establishing a connection to SQL Server” – while trying to use Dataverse connector in Power BI by Nishant Rana
March 2, 2021
Agent scripts in Omnichannel and Customer Service Workspace – Dynamics 365 by Nishant Rana
March 2, 2021
Do you use FetchXML Builder? Please consider helping a friend out. by Nishant Rana
March 1, 2021 Originally posted on
ReadyXRM :
I use the FetchXML Builder on my Power Platform almost on a daily basis. It saves…
Activity Logging – Dynamics 365 Apps by Nishant Rana
February 24, 2021 Microsoft 365 Security and Compliance Center – provides easy access to the …
Continue reading “Activity Logging – Dynamics 365 Apps”
Azure Cheat Sheet by Nishant Rana
February 23, 2021 Originally posted on
Microsoft Azure Articles.. :
Microsoft Azure Articles.. View original post
Check access to a record in Dynamics 365 by Nishant Rana
February 23, 2021 Using the Check Box button in the command bar, the user can …
Continue reading “Check access to a record in Dynamics 365”
In-app or Push notification – Model-driven App – 2021 Release Wave 1 Power Apps / Dynamics 365 by Nishant Rana
February 17, 2021
Clone A Record by Nishant Rana
February 10, 2021 Originally posted on
Microsoft Dynamics CRM / 365 :
Clone A Case Record : Cloning is one of the methods which can reduce the time…
Extracting attachments from Notes in Dynamics 365 / Dataverse by Nishant Rana
February 10, 2021
Improved search experience now adds Quick Actions – 2021 Release Wave 1 – Dynamics 365 by Nishant Rana
February 9, 2021
Copy an environment – duration – Dynamics 365 by Nishant Rana
February 4, 2021
Form Component Control in Dynamics 365 / Power Apps by Nishant Rana
February 3, 2021 Form Component Control can be used to update the parent record -through …
Continue reading “Form Component Control in Dynamics 365 / Power Apps”
Sending an email using AddressUsed attribute of ActivityParty entity in Dynamics 365 by Nishant Rana
February 2, 2021
Create a custom API of type function in Dynamics 365 / Microsoft Dataverse by Nishant Rana
January 27, 2021
Custom API Request Parameter entity in Dynamics 365 / Microsoft Dataverse by Nishant Rana
January 26, 2021
Dynamics Portals – Using SSL Certificates and Custom Domains – Part 1: Generate Certificate Request by Nishant Rana
January 25, 2021 Originally posted on
CRM & Coffee :
Hello team, This week I have been working with Certificates a LOT, and let me tell…
Export key attribute uniquename for component CustomAPI must start with a valid customization prefix exception while creating Custom Action in Dynamics 365 by Nishant Rana
January 22, 2021
Force Sync Users from Azure AD to Dynamics CRM by Nishant Rana
January 20, 2021 Originally posted on
Power Platform Learning :
When an new Environment is created, it takes more than an hour or some times a…
Dynamics CRM On Premise Maintenance Jobs! by Nishant Rana
January 20, 2021 Originally posted on
Ricky Safford Development Repository :
Please remember to reschedule these maintenance jobs after the installation of CRM is completed. Maintenance Job…
Allowed Custom Processing Step Type (AllowedCustomProcessingStepType) property of Custom API in Dynamics 365 / Microsoft Dataverse by Nishant Rana
January 20, 2021
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…
Like this: Like Loading...
Related
One thought on “Manage Dynamics 365 Web API with Azure API Management”