Azure WebJob Upload Fails with 'Bad Request' Error for Laravel Queue Worker Script

Veronica Donoso 0 Reputation points
2024-12-10T22:08:44.3466667+00:00

Issue Description

I am attempting to set up a WebJob in Azure Web App Service to run a Laravel queue worker (php artisan queue:work). However, when adding the WebJob, I consistently encounter the error: "Failed to add 'queue-worker' Bad request".

Steps Taken to Resolve the Issue

1. WebJob Script

I created a shell script named queue-worker.sh with the following content:

#!/bin/bash

Navigate to the app directory

cd /home/site/wwwroot

Run the Laravel queue worker

php artisan queue:work --sleep=3 --tries=3 --timeout=90

The script was saved in the scripts folder at the root of my Laravel app, alongside artisan, app, public, resources, etc.

2. File Permissions

The script has the correct permissions: -rwxr-xr-x.

3. File Encoding

Initially, the script had Windows-style line endings (CRLF). I converted it to Unix-style line endings (LF) using dos2unix and verified the output using cat -e.

4. ZIP File

I zipped the queue-worker.sh file into queue-worker.zip with the script placed at the root of the ZIP file.

5. App Service Configuration

My app is deployed using Azure Web App Service on a PremiumV2 (P1v2) plan, which supports WebJobs.

I confirmed the following application settings are correctly configured in Azure:

WEBSITE_CONTENTAZUREFILECONNECTIONSTRING: Set to the storage account connection string.

WEBSITE_CONTENTSHARE: Set to the file share name in the storage account.

6. Testing Script Locally

I tested the script locally successfully.

7. WebJob Configuration in Azure

Uploaded the queue-worker.zip file to Azure WebJobs:

Set the WebJob as Continuous.

Each attempt resulted in the error: "Failed to add 'queue-worker' Bad request".

Request for Assistance

I need help understanding why the WebJob upload fails with a "Bad request" error, despite verifying file structure, permissions, encoding, and App Service configuration. Is there any additional configuration or debugging step I should take to resolve this?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,093 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.