Dynamics 365 for Finance & Operations (AX) has an OData interface with which we can easily integrate third-party applications with it. The generation of the proxy class makes it easier to do .net programming against this OData endpoint by creating strongly typed classes for entities and attributes which will give IntelliSense support in Microsoft Visual Studio. It helps to speed up the development process and makes the development less prone to errors.
- Visual Studio 2017 (At the time of publishing this article, latest version of OData V4 Client Code Generator was only supported on VS 2017)
- Microsoft Dynamics 365 for Finance & Operations (AX)
Create client-side OData proxy:
1. The first step is to create a class library project and delete the default class file.
2. Now go to Tools Extensions and Updates.
3. Click on the Online section and search for the OData V4 Client Code Generator. Now download and install the OData V4 Client Code Generator and restart the Visual Studio
4. Once Visual Studio is restarted, we will be able to find and add 'OData Client' item into our project.
5. Now open the newly added ODataClient.tt file and fill in the 'MetadataDocumentUri' section with the AX OData URL as shown in the screenshot. Once this is done, save the file and this save will trigger the creation of the Proxy file.
When there are new entities and attributes added to the AX system and if you want them in your proxy file, we can re-generate the proxy file easily by right clicking on the ODataClient.tt file and clicking on the 'Run Custom Tool'.
6. Once the generation is completed, the proxy file will get saved onto the root folder of the project. We can then build the project to generate the DLL which can be uploaded to the Azure Functions or referenced in any .Net project for the access.
Please note that the entity should be explicitly exposed to the public in the AX system to be available in the proxy class.
This link ServiceSamples will give you plenty of samples to play with on how to use the proxy to authenticate and do CRUD operations against an AX system. In my next post we will see how we can use this proxy to integrate Dynamics 365 for Finance & Operations (AX) and CRM using Azure Functions.