Part 1 - Getting Connected with VS2017 and Connected Services

Now that we can use Visual Studio 2017 for F&O development, we have a newer and better way to generate OData clients. First, we'll cover what it takes to get everything setup. I typically use VS2019 for C# development so we'll be using that for most of this.

Create a new C# project

Name it and click create

Grab the "AuthenticationUtility" From https://github.com/microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples and put it into your solution folder. Add it to your project.

Next follow the sections named "Creating an application in Azure", "Adding permissions to Azure App", and "Registering service in D365FO" in this article to create the Azure App Register: https://www.d365ug.com/blogs/nandita-nityanandam/2018/11/20/third-party-integration-in-d365fo-using-odata. Don't follow anything else as things are different inside VS2017.

Next, go to Extension and install Connected Services (or confirm its already there)

Next, expand the AuthenticationUtility project, right click on References and select "Manage NuGetPackages". Click "Restore"

Next, open the ClientConfiguration.cs in AuthenticationUtility. Copy/paste in the values from the article earlier where we were creating the Azure App Register. As a side note, the F&O instance has to be on the same tenant as the C# app in order to be able to authenticate.

Next, right click on your console add an add a connected service.

Select OData Connected Service

Next, Fill out the values in the wizard. This is being executed on a local environment image. The full address being used is: https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/$metadata

Select the entities you want OData clients for. This will manage and auto-select any required underlying types. I suggest that you unselect all then select the entities are you interested in.

Next, select the following settings:

  • Enable entity and property tracking - ths enables change tracking on per instance basis for a scoped record equivalent using an oData client. Some entities won't work correctly without this and this is also (nearly) a requirement for all update operations.
  • Generate Multiple Files - I highly suggest you have this enabled just to break out each entity into its own set of files. If you are using development tools like ReSharper or similar, it makes it easier for those tools to scan the generated code base. 

Click Finish. This can take from 5 to 30 minutes to complete depending on the VM being used. And that's it. You're ready to start grabbing data from F&O. In the next article we'll start looking at read workloads.