Trying to create WebJob on App Service in Azure giving "Bad Request"

Phillip Parr 25 Reputation points
2024-05-26T19:13:40.25+00:00

I'm trying to set up a WebJob to run a PHP script on my App Service in Azure, but when I submit the form it's returning with a "Failed to add Process-FTP-Files, Bad Request". I can see in the developer panel the response from the server is a flat out 400. There's nothing that tells me why this is a bad request; the zip file contains 4 PHP files, one of which is called run.php and the others are included by that script.

Is Azure having a bad day, or have I done something stupid?

User's image

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
0 comments No comments
{count} vote

5 answers

Sort by: Most helpful
  1. Konstantinos Passadis 19,591 Reputation points MVP
    2024-05-26T19:33:31.8166667+00:00

    Hello @Phillip Parr

    Welcome to Microsoft QnA!

    Please verify :

    1. Zip File: Ensure all PHP files (including run.php and its dependencies) are at the root level of the ZIP archive, not within a subfolder.
    2. run.php: Azure WebJobs look for a file named run.{extension} (in your case, run.php) as the entry point. Make sure it's correctly named and present.
    3. Case Sensitivity: File names are case-sensitive. Double-check that run.php is lowercase.
    4. Hidden Files: Avoid including hidden files (e.g., .DS_Store) in the ZIP.

    Can we see the web.config ?

    --

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription

    Regards


  2. Mark Jensen 25 Reputation points
    2024-06-24T17:28:13.5866667+00:00

    Same issue until i created a storage blob and connected a path from the configuration menu.
    At this point i migrated from Bad Request to "Failed to add '<name of webjob' - There was an error creating your webjob."

    User's image

    User's image

    0 comments No comments

  3. Rafael Pinheiro Farias 0 Reputation points
    2024-10-22T12:10:06.9566667+00:00

    same problem here. i am trying to debug it. I create file called run.php and just add phpinfo() zip as run.zip and upload it

    but after upload it got error

    <?php
    phpinfo();
    ?>
    

    User's image


  4. Mark Jensen 25 Reputation points
    2024-10-22T14:31:45.7133333+00:00

    I've spoken quite lengthily with Azure support and their one of the WebJob engineers and currently Webjobs do NOT support PHP scripts despite it being stated otherwise elsewhere.

    You have two options.

    1. Deploy a bash script (run.sh) to run php script.php (php is installed on the host)
    2. Deploy a bash script (run.sh) to curl a php endpoint on your WebApp.

    I personally opted for number 2 as i was then able to leverage envrioment variables and more easily allow for CI/CD instead of manageing and uploading php files.

    filename: run-{jobname}-prod.sh

    #!/bin/bash
    
    # Your Bash commands here
    echo "{jobname} Job start"
    
    # URL to connect to
    url="https://my.webapp.com/path/to/script.php"
    
    # GET data
    getData="param={param}"
    
    # Make the GET request
    curl -s -G --data "$getData" "$url" > /dev/null 2>&1
    
    echo "{jobname} Job end"
    

    replace text in { } (curly brackets)

    0 comments No comments

  5. Mark Jensen 25 Reputation points
    2024-10-22T22:16:16.92+00:00

    Realized I might want to share this

    I've spoken quite lengthily with Azure support and their one of the WebJob engineers and currently Webjobs do NOT support PHP scripts despite it being stated otherwise elsewhere.

    You have two options.

    1. Deploy a bash script (run.sh) to run php script.php (php is installed on the host)
    2. Deploy a bash script (run.sh) to curl a php endpoint on your WebApp.

    I personally opted for number 2 as i was then able to leverage envrioment variables and more easily allow for CI/CD instead of manageing and uploading php files.

    filename: run-{jobname}-prod.sh

    BashCopy

    #!/bin/bash
    
    # Your Bash commands here
    echo "{jobname} Job start"
    
    # URL to connect to
    url="https://my.webapp.com/path/to/script.php"
    
    # GET data
    getData="param={param}"
    
    # Make the GET request
    curl -s -G --data "$getData" "$url" > /dev/null 2>&1
    echo "{jobname} Job end"
    

    replace text in { } (curly brackets)

    0 comments No comments

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.