Referring to one of my previous posts, where I described how to create an OData client for Microsoft Dynamics 365 for Finance and Operation, I now want to show you, how to use this client with an Azure Function. The problem with the previously shared solution is that you’re not able to use a temporary file for the client when running an Azure Function, because you do not have access to the file system. The solution for this problem is to reduce the client to the entities you need, to reduce the size of the client.
First you need to get the metadata XML as desired in my previous posts. Next you have to find out which entities you need. Then you’re ready to put both information into the C# tool you can find in the following repository: ODataClientXmlFiltering
The result of executing the C# tool is a “reduced” metadata XML that you can use to generate an OData client without a temporary file.
Please note that the tool in the current state removes all OData actions from the metadata XML. If you´re having a smarter solution feel free to send me a pull request.
Now you’re thinking why should I use an OData client in an Azure Function? My real life example is a monitor feature, where we´re checking the response time of the OData interface and writing the results to an Azure SQL database, to visualize this in PowerBI. To get a feeling what’s possible you can see the results in the banner of this post.
Ievgen Miroshnikov posted a hint to a “smarter” solution, to “reduced” the metadata XML, on Twitter which has been shared by Shashi Sadasivan. You can find the solution on GitHub: https://github.com/shashisadasivan/EDMXTrimmer