appinsights_set_connection
Securely register the D365 F&O environment's Application Insights / Log Analytics connection for the CURRENT session. The client secret is encrypted in memory (AES-256-GCM), never written to disk and never echoed back. Once set, appinsights_query and appinsights_diagnose_slowness use it automatically until it expires or you call appinsights_clear_connection.
HOW TO GET THE VALUES: workspaceId -- the Log Analytics WORKSPACE ID (GUID, not the App Insights app id) behind the Application Insights resource the environment is linked to (D365FO: System administration > Monitoring and Telemetry parameters > Application Insights Registry tab shows the connection string; the workspace id is on that Log Analytics workspace resource's Overview blade in the Azure Portal). tenantId/clientId/clientSecret -- an Entra ID app registration granted the 'Log Analytics Reader' (or 'Monitoring Reader') role on that workspace resource (Azure Portal > workspace > Access control (IAM) > Add role assignment). Read-only -- no write access is ever needed or used.
In a locked server deployment (APPINSIGHTS_LOCK_SERVER_CONFIG=true) this tool is disabled and the server's own environment credentials are used instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientId | Yes | App registration (client) id (GUID), granted Log Analytics Reader on the workspace. | |
| tenantId | Yes | Entra (Azure AD) tenant id (GUID). | |
| ttlMinutes | No | Minutes the connection stays cached for this session (1-480). Default 60. | |
| workspaceId | Yes | Log Analytics workspace ID (GUID) behind the linked Application Insights resource. | |
| clientSecret | Yes | App registration client secret. Encrypted in memory; never logged or persisted. |