projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.12k stars 654 forks source link

A WebJob uploaded to Linux App Service is not working #3510

Closed anttikes closed 4 months ago

anttikes commented 4 months ago

App Service Plan: Linux, B1 App Service runtime: NodeJS 18

Repro steps:

  1. Take the attached JavaScript file index.zip
  2. Open Kudu SSH console
  3. Create a folder /home/site/jobs/triggered/TestJob
  4. Use nano to create a file "run.js", and copy-paste contents from the source file
  5. Close nano, saving changes

Expected result: The WebJob should be listed in the Portal -> WebJobs.

Actual result: The job is nowhere to be found, and it doesn't seem to run.

Notes: Uploading the file to any of the following folders doesn't seem to help:

Attempting to upload the file by putting it into a run.zip and from the portal results in an error "Bad request".

According to documentation WebJobs on Linux is currently in preview but the document does not say that I should enable some preview bit or opt-in to some specific feature in order to utilize it.

anttikes commented 4 months ago

Note that if I use Postman and try to issue GET /api/webjobs I am always greeted with what looks like a HTML page that says "Session expired".

If I use exact same credentials but issue GET /api/scm/info instead then I get a proper response. So, the credentials are working and so is the Kudu API in general. But for some inexplicable reason the WebJobs portion isn't.

Also note that if I try to do any of these steps in a Windows App Service Plan then everything works, the API and all.

anttikes commented 4 months ago

If I monitor the Log Stream blade of the App Service while trying to use Postman, or pressing the "Refresh" button on the WebJobs blade then the following is printed to the console:

2024-04-26T12:53:27.3185176Z Exception Message : One or more errors occurred. (Connection refused (169.254.131.2:50555))
2024-04-26T12:53:27.3468771Z Exception StackTrace :    at System.Threading.Tasks.Task`1.get_Result()
2024-04-26T12:53:27.3470761Z    at Kudu.Services.Diagnostics.HttpRequestExtensions.ForwardToContainer(String route, HttpRequestMessage request) in /tmp/KuduLite/Kudu.Services/Diagnostics/HttpRequestExtensions.cs:line 51
2024-04-26T12:53:27.3470995Z    at Kudu.Services.Jobs.JobsController.ForwardJobRequestToContainer(String route) in /tmp/KuduLite/Kudu.Services/Jobs/JobsController.cs:line 198
2024-04-26T12:53:27.3471102Z    at Kudu.Services.Jobs.JobsController.ListAllJobs() in /tmp/KuduLite/Kudu.Services/Jobs/JobsController.cs:line 28
2024-04-26T12:53:27.3471223Z    at lambda_method75(Closure , Object , Object[] )
2024-04-26T12:53:27.3471324Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
2024-04-26T12:53:27.3471447Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
2024-04-26T12:53:27.3471545Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2024-04-26T12:53:27.3471674Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
2024-04-26T12:53:27.3471766Z --- End of stack trace from previous location ---
2024-04-26T12:53:27.3471857Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
2024-04-26T12:53:27.3471974Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2024-04-26T12:53:27.3472074Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
2024-04-26T12:53:27.3472308Z --- End of stack trace from previous location ---
2024-04-26T12:53:27.3472408Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2024-04-26T12:53:27.3472542Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
2024-04-26T12:53:27.3472638Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2024-04-26T12:53:27.3472737Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
2024-04-26T12:53:27.3472850Z --- End of stack trace from previous location ---
2024-04-26T12:53:27.3472946Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2024-04-26T12:53:27.3473075Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2024-04-26T12:53:27.3473173Z    at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
2024-04-26T12:53:27.3473293Z    at Kudu.Services.Web.Tracing.TraceMiddleware.Invoke(HttpContext context) in /tmp/KuduLite/Kudu.Services.Web/Tracing/TraceMiddleware.cs:line 107
2024-04-26T12:53:27.4920402Z fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
2024-04-26T12:53:27.4922398Z       An unhandled exception has occurred while executing the request.
2024-04-26T12:53:27.4922604Z       System.Net.Http.HttpRequestException: Connection refused (169.254.131.2:50555)
2024-04-26T12:53:27.4922731Z        ---> System.Net.Sockets.SocketException (111): Connection refused
2024-04-26T12:53:27.4922839Z          at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 )
2024-04-26T12:53:27.4922941Zat System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs , ValueTask , CancellationToken )
2024-04-26T12:53:27.4923068Z          at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String , Int32 , HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4923159Z          --- End of inner exception stack trace ---
2024-04-26T12:53:27.4923348Z          at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String , Int32 , HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4923474Z          at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4923601Z          at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4923694Z          at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage )
2024-04-26T12:53:27.4923785Z          at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken )
2024-04-26T12:53:27.4923907Z          at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4924002Z          at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage , Boolean , Boolean , CancellationToken )
2024-04-26T12:53:27.4924122Z          at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4925042Z          at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage , Boolean , CancellationToken )
2024-04-26T12:53:27.4925213Z          at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage , HttpCompletionOption , CancellationTokenSource , Boolean , CancellationTokenSource , CancellationToken )
2024-04-26T12:53:27.4925330Z          at Kudu.Services.Web.Tracing.TraceMiddleware.Invoke(HttpContext context) in /tmp/KuduLite/Kudu.Services.Web/Tracing/TraceMiddleware.cs:line 107
2024-04-26T12:53:27.4925455Z          at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
2024-04-26T12:53:27.4925551Z          at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
2024-04-26T12:53:27.5116059Z X-MS-VIA-EXTENSIONS-ROUTE = true
2024-04-26T12:53:27.5199950Z httpRequest.Method = GET
2024-04-26T12:53:27.5200927Z X-MS-CLIENT-AUTHORIZATION-SOURCE = RoleBased
2024-04-26T12:53:27.5201103Z X-MS-CLIENT-ROLEBASED-CONTRIBUTOR =
2024-04-26T12:53:27.5201355Z URI path = /Error

The IP address is the same that's printed on the SSH console when I open it via Kudu but I am not sure what is supposed to be running on port 50555.

jvano commented 4 months ago

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure: https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano Azure App Service