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
- You know and understand how to make Custom API calls
- You know SQL query language
- You understand the underlying table structure for your environment.
Dependencies
The following are dependencies for this feature:
- 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:
Navigate to the app user registration in Azure.
In a separate window, open the managed identity admin utility in Dynamics (...crmx.dynamics.com/webresources/klevr_PluginManagedIdentity.html).
Copy the App Registration Object ID and Tenant ID from Azure into the Plugin Managed Identity page and click save.
In Azure, go to the Certificates and Secrets section on the managed identity.
Click on Federated Credentials.
Click Add Credential.
Select "Other Issuer" as the scenario.
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