2017-09-25 44 views
0

我已經創建了一個AWS功能,以本地模式完美地工作,但是當在AWS拉姆達執行,我得到:AWS LAMBDA C# - 失敗查詢SQL與小巧玲瓏的

過程完成請求

前退出

該函數使用Dapper連接到RDS SQL連接。我檢查了安全組,入站/出站規則是正確的。

LambdaLogger.Log($"Listando doacao em visita"); 

     using (SqlConnection conexao = new SqlConnection(_connectionString)) 
     { 
      LambdaLogger.Log($"Conexao aberta"); 

      var weekDay = (int)DateTime.Now.DayOfWeek; 
      var stringSql = [email protected]"{_query} 
        WHERE 
        p.status = {(int)StatusPedido.DoacaoEmVisita} and 
        p.datainclusao <= Getdate() - 7 
       "; 

      LambdaLogger.Log($"Query gerada"); 


      //the function exited on this line 
      var query = conexao.Query<AlertaDisponibilidadeERetiradaDTO, EnderecoDTO, AlertaDisponibilidadeERetiradaDTO>(
       stringSql 
       , (pedido, endereco) => 
       { 
        pedido.Endereco = endereco; 
        return pedido; 
       }, splitOn: "IdEndereco"); 

      LambdaLogger.Log($"Query executada."); 

      return query; 
     } 

我包裹着的try/catch代碼,登錄爲何發生異常,但unfortunely功能瞬間存在,我無法知道爲什麼。

回答

0

過程完成請求

指示異常與LAMBDA之前退出。檢查AWS Cloudwatch是否處理並記錄到cloudwatch的異常。

如果你沒有看到任何日誌記錄,你的依賴可能會失敗。

希望它有幫助。

+0

CloudWatch的只是記錄了「LambdaLoger.Log」,我裹着嘗試捕捉的代碼,但它不是沒有捉襟見肘。我沒有任何日誌查看發生了什麼 –

0

我在降級對.NET執行標準的所有包dependings解決我的問題1.6.1 => 1.6.0