Timeout issue with Parallel connections from azure function to snowflake

My logic app flow is shown below in the image.
In my Azure logic app, I am calling azure function, http_python_sp_exec_sf, (Execute SP Call) in a for each loop. The for each will run for 10 SPs. Functionality of the azure func, http_python_sp_exec_sf, is that it connects to snowflake and then submits a query to snowflake to call a SP, the SP name is passed as input to azure function along with other parameters. The azure function returns submitted query id after submitted query to snowflake, and I keep on polling on query id status (using http_python_sf_query_fetchall). If status is returned as success then the loop exists and get the executed statement returned statement. This is done to avoid the timeout error and azure function can execute within time limits. I have added a delay of 30 secs in polling before checking the query status on snowflake. In end, I append the newly generated table (as a result of the SP) to some other table (using http_python_sf_query_fetchall). When I ran for 4,5 SPs, the for each works fine but when I executed 10 SPs, the azure function returns timeouts randomly for different iterations. Questions below:

  1. I dnt understand why there is timeout error. All I am doing in the azure function is to submit the query and return. Is there a parallel snowflake connection issue? By default I have permission to run 16 parallel SF connections in parallel.
  2. Do I need to have a delay between opening the connections with Snowflake? I tried putting a delay of 30 sec after every snowflake query but didn’t help.

P.S. I am connecting to snowflake from azure logic app via azure function (as snowflake connector in azure logic app was not working as we are using public/private key authentication).

Below is the azure function code.

@app.route(route=”http_python_sp_exec_sf”)
def http_python_sp_exec_sf(req: func.HttpRequest) -> func.HttpResponse:
logging.info(‘Python HTTP trigger function processed a request. – http_python_sp_exec_sf’)

token = req.params.get('token') # secret
sp_name = req.params.get('sp_name')
start_date = req.params.get('start_date')
end_date = req.params.get('end_date')

if not token:
    try:
        req_body = req.get_json()
    except Exception as e:
        return func.HttpResponse(str(e))
    else:
        try:
            token = req_body.get('token')
            sp_name = req_body.get('sp_name')
            start_date = req_body.get('start_date')
            end_date = req_body.get('end_date')

            
            cur,conn = snowflake_connection_public_private_key() 
            logging.info('connection Established with snowflake  - http_python_sp_exec_sf')

            query_tab1 ="select  col1 from test1"
            query_tab2="select  col2 from test1"             

            sf_call_query = "CALL sc."+"SP_"+sp_name+"_SP2"+"('"+sp_name+"_tmp, '"+query_tab1+"','"+query_tab2+"','"+start_date+"','"+end_date+"');"
            response_sf_call_query = cur.execute(sf_call_query)
            logging.info('Query submitted to snowflake')
            query_id = cur.sfqid
            logging.info('Returning Query ID')

            cur.close()
            conn.close()
            logging.info('Snowflake Connection Closed')

            ret_json = {"SP_Name":sp_name, "query_id":query_id}
            
            return func.HttpResponse(json.dumps(ret_json), mimetype="application/json") 

        except Exception as e:                  
            return func.HttpResponse(str(e))


@app.route(route="http_python_sf_query_fetchall", auth_level=func.AuthLevel.ANONYMOUS)
def http_python_sf_query_fetchall(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request - http_python_sf_query_fetchall')

query = req.params.get('query')

    if not query:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            try:
                query = req_body.get('query') 
                cur, conn = snowflake_connection_public_private_key() 
                logging.info('connection Established with snowflake - http_python_sf_query_fetchall')
                ret = cur.execute(query).fetchall()  

            except Exception as e:
                    return func.HttpResponse(str(e))
            
            cur.close()
            conn.close()

            ret_json = {"response_query":ret[0][0],"response_all":ret}
            return func.HttpResponse(json.dumps(ret_json), mimetype="application/json") 

    if query:
        return func.HttpResponse(f"Hello from http_python_sf_query, {query}. This HTTP triggered function executed successfully.")
    else:
        return func.HttpResponse(
             "This HTTP triggered function http_python_sf_query executed successfully. Pass a name in the query string or in the request body for a personalized response.",
             status_code=200
        )

enter image description here

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật