Using a Helper Logic App for CDS Web API
  • 26 Apr 2020
  • 3 Minutes to read
  • Contributors
  • Comment
  • Dark
    Light
  • PDF

Using a Helper Logic App for CDS Web API

  • Comment
  • Dark
    Light
  • PDF

Article Summary

One of the approaches we have been using that works really nicely is to wrap the use of the CDS Web API with a helper logic app. The benefits to doing this are you can encapsulate the configuration for the CDS authentication and connection within the helper logic app and then simplify the implementation details within the Logic App which implements your processing logic.

There are a few levels you can take this to, you could go as far as creating some data service type logic apps for each of the things you need to use from CDS or you could have a single logic app which wraps most of the work and then your calling logic app is aware of some of the implementation details of CDS but not all of them.

The Helper

In the helper logic app I have some variables with my settings for the tenant id, and other service principal info. This is just for demo purposes and in the real world you should probably be looking these up from Key Vault or setting them as a secure property at deployment time.

After this I am extracting some headers from the incoming request to the helper logic app. The headers I am using are:

  • api_method which allows the caller to indicate which HTTP method will be used.
  • api_local_path which allows the caller to specify the path on the CDS api which I will add to the base url.

At this point the helper will call the CDS API and return the response to the caller. The below picture shows the configuration of the HTTP action.

image.png

I then configure the response Run After to run on success and failure and return the response from the HTTP action and its status code like below.

image.png

Using the Helper

Originally the Logic App I had which was using the CDS via Web API had a number of calls to CDS configured using HTTP actions. Below shows the example of one inserting an entity via an upsert.

image.png

You can see that while its pretty simple, each action will need configuration for the authentication and base url. The only things that are different about each of the HTTP actions calling CDS are:

  • HTTP Method
  • The path for the url (the base url is the same each time)
  • The body of the request
  • The body of the response

By using the helper logic app which encapsulates a reusable HTTP action I am able to modify the Logic App which implements my process to use the helper logic app to do the calls to CDS instead of using the HTTP action itself. The modified logic app will have calls to the helper logic app like below.

image.png

You can see now I only need to care about the body of the message, the path on the api and method. I no longer need to worry about all of the authentication which is handled by the helper.

Whats the benefit

The overall benefit is that rather than worrying about the settings for the authentication on every HTTP action, I can wrap this in the helper logic app and then the service principal and base url are configured in 1 place. This very much simplifies my configuration settings when I am developing a lot of interfaces which use CDS. There is only 1 logic app that needs to worry about the things that change per environment as we move from dev to test to production. From a productivity perspective this can significantly improve how quickly I can implement my interfaces and makes them easier to support.


Was this article helpful?