Good catch on the OAuth token refresh delay. Let me provide a comprehensive solution addressing all the key areas:
1. MCP Server Batch Size Configuration:
Set your batch size to 50-75 records maximum for demand forecast operations. Navigate to System Administration > MCP Server Configuration > Batch Processing and update:
mcp.batch.demandForecast.maxSize=75
mcp.batch.demandForecast.timeout=180
2. Power Apps Flow Pagination Logic:
Implement proper chunking in your Power Apps flow. Use the ‘Apply to each’ control with a concurrent limit of 1, and add a 5-second delay between batches:
- Split your forecast dataset into arrays of 75 records
- Process each chunk sequentially
- Include error handling with retry logic (max 3 attempts)
- Use ‘Scope’ controls to manage transaction boundaries
3. OAuth2 Scope Configuration:
Update your Azure AD app registration to include these specific scopes:
- Dynamics.SupplyChain.ReadWrite (REQUIRED for Supply Planning)
- Dynamics.SupplyChain.DemandForecast.All
- offline_access (for token refresh)
In your Power Apps connection, refresh the authentication to pick up the new scopes. This should reduce token refresh time from 15-20 seconds to under 2 seconds.
4. Request Timeout Tuning:
Increase the MCP server request timeout in web.config:
<httpRuntime executionTimeout="180" />
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>
Also configure your Power Apps HTTP action timeout to 180 seconds to match.
5. Diagnostic Logging:
Enable these logging categories in System Administration > MCP Configuration > Diagnostics:
- MCP.DemandForecast.Sync (Level: Verbose)
- MCP.OAuth.TokenRefresh (Level: Info)
- MCP.Batch.Processing (Level: Info)
Monitor the logs for 24-48 hours to establish baseline performance metrics. You should see batch processing complete in 30-45 seconds per chunk with proper configuration.
Additional Recommendations:
- Schedule large forecast uploads during off-peak hours (early morning)
- Implement a status tracking table to monitor which batches have been processed
- Consider using the Data Import/Export Framework (DIXF) for initial bulk loads over 5,000 records
- Set up Application Insights alerts for MCP timeout events
After implementing these changes, your 500-record dataset should process in approximately 8-10 minutes total (7 batches × 75 seconds average per batch) with much higher reliability. The key is matching batch sizes to your MCP server capacity while ensuring proper OAuth scope configuration to eliminate token refresh delays.
This draft is based on general Microsoft Dynamics 365 knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.