![]() |
#1 |
Участник
|
sertandev: Empowering D365 FO service endpoints with Azure API Management service
Источник: http://devblog.sertanyaman.com/2019/...ement-service/
============== In Dynamic 365 for Finance and Operations the service endpoints are deployed automatically upon build, without the need of any additional setup or configuration we used to do with legacy AIF services. However, in the current D365FO service endpoints, we do not have many of the configuration possibilities which were provided by WCF configuration and inbound/outbound port management before. Azure API management service is an Azure service that provides a highly configurable front end for many sorts of Azure and 3rd party web api services, as well as for our D365FO service endpoints. ![]() Adding D365FO API services to Azure API management brings up many advantages. Some of those are :
Unfortunately, in the time of writing, it is not a straightforward process, like clicking a button on D365FO UI and adding your service directly to API management. So we need to struggle a bit with some configurations to be able to achieve this.. To begin with, we need a D365FO API service for testing in API management service. In this example I will use the same service I have created for my previous blog post, the visit schedule service in How to connect a Native Android Application to Dynamics 365 FO. You can download and install the D365FO project file for this service from the link below : https://github.com/sertanyaman/nativ...dynamics-365fo Then, create an API management instance from Azure portal. The name you give to your management instance will be the used as the url prefix to access all your API services like “https://.azure-api.net/</em>“. After the service is created (will take a long time) open it in Azure portal, go to products tab and create a new Product. This step is optional for testing, but it is a good practice to use a product for all D365FO services to organize them together from the beginning: ![]() Then we need to register an application ID for our API management frontend to access D365FO using Azure AAD, as described in the link below : https://docs.microsoft.com/en-us/azu...t-register-app choose “Accounts in any organizational directory” option in the creation of your app registration and note your application (client) ID GUID after the creation. We will use that later. Go to API permissions tab from here and add the following permission to your app registration: ![]() ![]() ![]()
![]() ![]() ![]() Now lets add our service operation. The visit schedule demo service has two service operations. Here we add the “getNewTasks” operation to the API management service : ![]() Is that all of it? Is our service ready for testing now? No, not yet!… Now go back to the App registration page in your Azure AAD and in the Authentication tab add the following value with type “Web” in your Redirect URIs : “https://.portal.azure-api.net/docs/s...allback” ![]() Now in the end, we are ready to test. Testing First create some demo records in visit scheduling to be picked up by the service. Open the visit scheduler form and enter some records: ![]() ![]() On the request body, we need to fill the parameters to call our service in JSON format. We have only one parameter, which is “_worker”, so add a JSON value for the worker id (the worker id we created demo data for) as shown above. Leave the rest of the values in the screen and hit “Send” and Voila!. If everything is correctly set, you will see the results coming from the service as shown below : ![]() And what about testing the API management frontend service directly using a 3rd party application? To achieve this, you need the subscription keys that are created for your product in Api management (for product D365). Go to the subscriptions tab and copy the key value from the primary key of your product’s default subscription (Or be lazy and copy it from the trace window for the previous test). Then use your favorite REST client, here I will use PostMan, and setup a call to your API management operation frontend URL, like shown below. ![]() Ocp-Apim-Subscription-Key”. For header value, paste the subscription key you have copied. Now we also need to setup an AAD authorization to be able to acquire a token and call our service. PostMan easily arranges that for you. Go to the authorization tab and select OAuth 2.0. Click “GetNewAccessToken” and from the popup select Grant Type of “Authorization Code”. Fill in everything just the same as you have done in the API management OAuth2 setting, for the CallBack URL, just select one of the redirect URLs you setup for your AAD app registration. Click Request button and follow the steps for AAD authorization. Once finished, a token will be shown to you, click “Use token” on the bottom and you are done. ![]() After that is done, go back to the postman window and click “Send”. You will see the results coming (again if everything is setup correctly) : ![]() ![]() Источник: http://devblog.sertanyaman.com/2019/...ement-service/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
Теги |
apim, azure, d365fo |
|
|