Search code examples
c#azureazure-webjobsssh.net

Deployed Azure WebJob HRESULT E_FAIL has been returned from a call to a COM component


I just deployed a webjob in our Azure App Service and when i tested it, it returned this error

"Error HRESULT E_FAIL has been returned from a call to a COM component."

the application just retrieves a file from SFTP server then process the csv file using streamReader

Console.WriteLine("Reading lines from : " + file.FullName);
Console.WriteLine("SFTP Directory : " + client.WorkingDirectory);

var lines = new List<string>();
using (var stream = new StreamReader(client.OpenRead(file.FullName), ASCIIEncoding.ASCII))
{
    while (!stream.EndOfStream)
    {
        lines.Add(stream.ReadLine());
    }
    lineArray = lines.ToArray();
}

This works when I run it locally. but when its deployed in Azure its not working. Not sure what I'm missing out.

Library used for SSH: SSH.NET (Renci) 2020.0.2

UPDATE: (the full exception)

[10/19/2022 08:38:40 > 18cb2c: ERR ] Unhandled Exception: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Navigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers) [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Windows.Forms.WebBrowser.PerformNavigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers) [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Windows.Forms.WebBrowser.set_Url(Uri value) [10/19/2022 08:38:40 > 18cb2c: ERR ] at OfficeDevPnP.Core.AuthenticationManager.<>c__DisplayClass30_0.b__0() [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) [10/19/2022 08:38:40 > 18cb2c: ERR ] at System.Threading.ThreadHelper.ThreadStart() [10/19/2022 08:38:40 > 18cb2c: SYS INFO] Status changed to Failed [10/19/2022 08:38:40 > 18cb2c: SYS ERR ] Job failed due to exit code -532462766


Solution

  • Thanks to Panagiotis, I found the issue! I was using the authentication manager of OfficeDevPnP.

    OfficeDevPnP.Core.AuthenticationManager authManager = new OfficeDevPnP.Core.AuthenticationManager();
    

    I removed it and it worked already.