web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Facing Timeout issue w...
Power Automate
Suggested Answer

Facing Timeout issue while patching to sql server from a cloud flow

(0) ShareShare
ReportReport
Posted on by 9
Can anyone please help in resolving the issue.
 
 
 
 
Please find the below error description,
 
{
  "error": {
    "code": 504,
    "source": "flow-apim-europe-002-northeurope-01.azure-apim.net",
    "clientRequestId": "d47ad93d-1e0c-4610-ae30-77e9cdee74b8",
    "message": "BadGateway",
    "innerError": {
      "status": 504,
      "message": "Hosting Exception.\r\n     inner exception: Timeout expired. The timeout period elapsed prior to completion of the operation.\r\nclientRequestId: d47ad93d-1e0c-4610-ae30-77e9cdee74b8",
      "error": {
        "message": "Hosting Exception.\r\n     inner exception: Timeout expired. The timeout period elapsed prior to completion of the operation."
      },
      "source": "sql-we.azconn-we-002.p.azurewebsites.net"
    }
  }
}
Categories:
I have the same question (0)
  • stampcoin Profile Picture
    5,158 Super User 2026 Season 1 on at
    When you run the SP on server side, how long it will take do you think ?
    do you use on-premises data gateway ?
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,
     

    Solution 1: Optimize Your SQL Query

    Check your current SQL query for:


    • Large data retrievals - Use TOP or LIMIT clauses

    • Missing indexes - Ensure proper indexing on WHERE clause columns

    • Complex JOINs - Simplify or break into smaller queries

    • Aggregations - Use more efficient GROUP BY operations


    •  

    Example optimization:

     
    -- Instead of:
    SELECT * FROM LargeTable WHERE SomeColumn = 'Value'
    
    -- Use:
    SELECT TOP 1000 Column1, Column2, Column3 
    FROM LargeTable 
    WHERE SomeColumn = 'Value' 
    ORDER BY DateColumn DESC
     

    Solution 2: Break Large Operations into Smaller Chunks

    For large data operations:


    1. Replace single large query with multiple smaller ones

    2. Use pagination with OFFSET and FETCH

    3. Process in batches of 100-1000 records

    4.  

    Example approach:

    sql
    -- Query 1: Get count
    SELECT COUNT(*) FROM YourTable WHERE Condition
    
    -- Query 2: Get first batch
    SELECT * FROM YourTable WHERE Condition ORDER BY ID OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY
    
    -- Query 3: Get second batch
    SELECT * FROM YourTable WHERE Condition ORDER BY ID OFFSET 100 ROWS FETCH NEXT 100 ROWS ONLY

    Solution 3: Use Parallel Processing

    In your Power Automate flow:


    1. Split large operations into multiple parallel actions

    2. Use "Apply to each" with concurrency set to 2-4

    3. Process different data sets simultaneously

    4.  

    Advanced Solutions

    Solution 4: Implement Retry Logic

    Add retry policy to your SQL action:


    1. Click on your SQL action

    2. Go to Settings (three dots menu)

    3. Configure Retry Policy:

      • Type: Exponential Interval

      • Count: 3-5 attempts

      • Interval: PT10S (10 seconds)

      • Minimum: PT5S

      • Maximum: PT1M

    4.  

    Solution 5: Use Stored Procedures

    Create optimized stored procedures:

    sql
    CREATE PROCEDURE GetOptimizedData
        @Parameter1 VARCHAR(50),
        @MaxRecords INT = 1000
    AS
    BEGIN
        SET NOCOUNT ON;
        
        SELECT TOP (@MaxRecords) 
            Column1, Column2, Column3
        FROM YourTable 
        WHERE Column1 = @Parameter1
        ORDER BY DateColumn DESC;
    END

    In Power Automate:


    • Use "Execute stored procedure (V2)" action

    • Pass parameters efficiently

    • Get faster, optimized results

    •  

    Solution 6: Implement Async Pattern

    For very large operations:


    1. Trigger operation and get operation ID

    2. Use "Delay" action to wait

    3. Check status periodically

    4. Retrieve results when complete

    5.  

    Flow Architecture Solutions

    Solution 7: Split Your Flow

    Instead of one large flow:


    1. Parent Flow: Triggers and manages process

    2. Child Flows: Handle specific SQL operations

    3. Use "Run a Child Flow" actions


    4.  

    Solution 8: Add Error Handling

    Configure run after settings:

    1. Add "Configure run after" to your SQL action
    2. Check: "is successful", "has failed", "has timed out"
    3. Add condition to handle timeout specifically

    Error handling flow:

    If SQL action times out:
    - Log the error
    - Send notification
    - Retry with smaller dataset
    - Use alternative approach
    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 921

#2
Valantis Profile Picture

Valantis 801

#3
Haque Profile Picture

Haque 588

Last 30 days Overall leaderboard