letsencrypt-siteextension icon indicating copy to clipboard operation
letsencrypt-siteextension copied to clipboard

Systematic error in AddCertifiate function

Open fkorsa opened this issue 5 years ago • 8 comments

On one of my app services, the AddCertificate function in the WebJobs fails consistently with the stack trace below. I can see however that the certificate for that website was correctly renewed, so it doesn't really matter that much to me; but the error may be a sign of something wrong in the code which you may want to investigate.

I have the same configuration (same application settings, app service plan, resource group) on a lot of other app services, so I have no idea what could be different on this one to cause that issue only there.

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.AddCertificate ---> System.InvalidOperationException : A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled). at System.Threading.Tasks.Task.Dispose(Boolean disposing) at System.Threading.Tasks.Task.Dispose() at async LetsEncrypt.Azure.Core.CertificateManager.AddCertificate() at D:\a\1\s\LetsEncrypt.SiteExtension.Core\CertificateManager.cs : 142 at LetsEncrypt.SiteExtension.Functions.AddCertificate(TimerInfo timerInfo,String input,String& output) at D:\a\1\s\LetsEncrypt.SiteExtension.WebJob\Functions.cs : 50 at lambda_method(Closure ,Functions ,Object[] ) at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker2.InvokeAsync(TReflected instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) End of inner exception at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)

fkorsa avatar Aug 01 '19 07:08 fkorsa

(Version 0.9.5)

fkorsa avatar Aug 01 '19 07:08 fkorsa

Same issue with my Azure WebApp. Changes in Azure, maybe? Subscribing for updates!

rbonestell avatar Aug 15 '19 19:08 rbonestell

I am seeing this issue on only one of my webapps on version 1.0.5.

mcdurdin avatar Jun 11 '20 01:06 mcdurdin

i had the same issue with the latest version, haven't figured out why

zhangpengchen avatar Jun 22 '20 15:06 zhangpengchen

Same issue here with 1.0.5.

[09/11/2020 14:16:44 > 683351: INFO] Exception while executing function: Functions.AddCertificate
[09/11/2020 14:16:44 > 683351: INFO] Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.AddCertificate ---> System.InvalidOperationException : A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled).
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose(Boolean disposing)
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose()
[09/11/2020 14:16:44 > 683351: INFO]    at async LetsEncrypt.Azure.Core.CertificateManager.AddCertificate() at D:\a\1\s\LetsEncrypt.SiteExtension.Core\CertificateManager.cs : 116
[09/11/2020 14:16:44 > 683351: INFO]    at LetsEncrypt.SiteExtension.Functions.AddCertificate(TimerInfo timerInfo,String input,String& output) at D:\a\1\s\LetsEncrypt.SiteExtension.WebJob\Functions.cs : 50
[09/11/2020 14:16:44 > 683351: INFO]    at lambda_method(Closure ,Functions ,Object[] )
[09/11/2020 14:16:44 > 683351: INFO]    at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker`2.InvokeAsync(TReflected instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 
[09/11/2020 14:16:44 > 683351: INFO]    End of inner exception
[09/11/2020 14:16:44 > 683351: INFO] Executed 'Functions.AddCertificate' (Failed, Id=0c55fd4d-2ff3-4ec0-8a99-2dfb27cd73a6)
[09/11/2020 14:16:44 > 683351: INFO] Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.AddCertificate ---> System.InvalidOperationException : A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled).
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose(Boolean disposing)
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose()
[09/11/2020 14:16:44 > 683351: INFO]    at async LetsEncrypt.Azure.Core.CertificateManager.AddCertificate() at D:\a\1\s\LetsEncrypt.SiteExtension.Core\CertificateManager.cs : 116
[09/11/2020 14:16:44 > 683351: INFO]    at LetsEncrypt.SiteExtension.Functions.AddCertificate(TimerInfo timerInfo,String input,String& output) at D:\a\1\s\LetsEncrypt.SiteExtension.WebJob\Functions.cs : 50
[09/11/2020 14:16:44 > 683351: INFO]    at lambda_method(Closure ,Functions ,Object[] )
[09/11/2020 14:16:44 > 683351: INFO]    at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker`2.InvokeAsync(TReflected instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 
[09/11/2020 14:16:44 > 683351: INFO]    End of inner exception
[09/11/2020 14:16:44 > 683351: INFO]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)
[09/11/2020 14:16:44 > 683351: INFO]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '0c55fd4d-2ff3-4ec0-8a99-2dfb27cd73a6'
[09/11/2020 14:16:44 > 683351: INFO] Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.AddCertificate ---> System.InvalidOperationException : A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled).
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose(Boolean disposing)
[09/11/2020 14:16:44 > 683351: INFO]    at System.Threading.Tasks.Task.Dispose()
[09/11/2020 14:16:44 > 683351: INFO]    at async LetsEncrypt.Azure.Core.CertificateManager.AddCertificate() at D:\a\1\s\LetsEncrypt.SiteExtension.Core\CertificateManager.cs : 116
[09/11/2020 14:16:44 > 683351: INFO]    at LetsEncrypt.SiteExtension.Functions.AddCertificate(TimerInfo timerInfo,String input,String& output) at D:\a\1\s\LetsEncrypt.SiteExtension.WebJob\Functions.cs : 50
[09/11/2020 14:16:44 > 683351: INFO]    at lambda_method(Closure ,Functions ,Object[] )
[09/11/2020 14:16:44 > 683351: INFO]    at Microsoft.Azure.WebJobs.Host.Executors.VoidMethodInvoker`2.InvokeAsync(TReflected instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 
[09/11/2020 14:16:44 > 683351: INFO]    End of inner exception
[09/11/2020 14:16:44 > 683351: INFO]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
[09/11/2020 14:16:44 > 683351: INFO]    at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)

hurtonypeter avatar Sep 14 '20 08:09 hurtonypeter

Can you reproduce this using my standalone WebJob, built on this extension? https://github.com/ohadschn/letsencrypt-webapp-renewer

ohadschn avatar Sep 15 '20 21:09 ohadschn

5 seconds, an await is missing in the code

redmij avatar Mar 29 '22 13:03 redmij

Getting an error. Can any one can help me out! Im using Azure Let's Encrypt Version 1.0.6 By SJKP

Error occoured only when install the cert job running.

Please see attached image for error details:- image

This stats of job running: image

umarofficial66 avatar Apr 07 '22 01:04 umarofficial66