Klevr Product Documentation logo

Execute SQL Custom API

This custom API allows you to execute a SQL qeury against the Table Data Service endpoint for the current environment.

Feature Overview

This custom API allows you to execute a SQL qeury against the Table Data Service endpoint for the current environment. This is useful for rollup queries, etc. The TDS is read only, so updates cannot be performed.

Assumptions

  1. You know and understand how to make Custom API calls
  2. You know SQL query language
  3. You understand the underlying table structure for your environment.

Dependencies

The following are dependencies for this feature:

  1. App Service connection with appropriate rights

Design Details

The feature allows a plugin to get a security token for a managed identity, configured for the plugin. This token alllows the plugin to access Azure Resources that has been configured to give access to the managed identity.

Security Considerations

Only a system admin or the elevated service account can execute this custom API.

The App Registration needs to be given access to dynamics, and be given a security role to access TDS.

The Managed Identity needs to be configured with the App Registration Details.

Configuration

If you do not have an existing app registration that you can use already, create a new one with CRM API permissions and add it as an application user to Dynamics as per usual

Configure the federated credentials:

1
Open the App Registration

Navigate to the app user registration in Azure.

2
Open the Managed Identity Admin Utility

In a separate window, open the managed identity admin utility in Dynamics (...crmx.dynamics.com/webresources/klevr_PluginManagedIdentity.html).

3
Copy the Registration Details

Copy the App Registration Object ID and Tenant ID from Azure into the Plugin Managed Identity page and click save.

4
Open Certificates and Secrets

In Azure, go to the Certificates and Secrets section on the managed identity.

5
Open Federated Credentials

Click on Federated Credentials.

6
Add a Credential

Click Add Credential.

7
Select the Scenario

Select "Other Issuer" as the scenario.

8
Copy the Federated Identity Values

Copy and paste the values from the Federated Identity Values section on the web resource into the federated identity configuration on Azure.

As mentioned above, you could use the same registration for mulitple environments. Just keep adding a federated credential per environment, with he right guids and settings as per above. It's recommended to use a seperate one for production though.

You are now ready to execute the API's or use the product functions that rely on these API's.

Last updated on