Prateek Naik
Prateek Naik

Reputation: 2802

Azure App Service Getting error while deploying REACT JS application

Getting error while deploying to azure app services from the editor.

4:48:55 pm ppdedsrftwu2-appservice1: Starting deployment...
4:48:56 pm ppdedsrftwu2-appservice1: Creating zip package...
4:49:00 pm ppdedsrftwu2-appservice1: Zip package size: 1.09 MB
4:49:04 pm ppdedsrftwu2-appservice1: Fetching changes.
4:49:06 pm ppdedsrftwu2-appservice1: Updating submodules.
4:49:06 pm ppdedsrftwu2-appservice1: Preparing deployment for commit id '2a73dbd291'.
4:49:06 pm ppdedsrftwu2-appservice1: Repository path is /tmp/zipdeploy/extracted
4:49:06 pm ppdedsrftwu2-appservice1: Running oryx build...
4:49:06 pm ppdedsrftwu2-appservice1: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version 10 -i /tmp/8d856447f426192 -p compress_node_modules=tar-gz --log-file /tmp/build-debug.log 
4:49:07 pm ppdedsrftwu2-appservice1: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
4:49:07 pm ppdedsrftwu2-appservice1: You can report issues at https://github.com/Microsoft/Oryx/issues
4:49:07 pm ppdedsrftwu2-appservice1: Oryx Version: 0.2.20200805.1, Commit: e7c39ede513143e9d80fd553f106f04268d770d4, ReleaseTagName: 20200805.1
4:49:07 pm ppdedsrftwu2-appservice1: Build Operation ID: |lvjLop9mFGA=.426fac1c_
4:49:07 pm ppdedsrftwu2-appservice1: Repository Commit : 2a73dbd2834715ba1fee5082d13b60
4:49:07 pm ppdedsrftwu2-appservice1: Detecting platforms...
4:49:07 pm ppdedsrftwu2-appservice1: Could not detect any platform in the source directory.
4:49:07 pm ppdedsrftwu2-appservice1: Error: Couldn't detect a version for the platform 'nodejs' in the repo.
4:49:09 pm ppdedsrftwu2-appservice1: Error: Couldn't detect a version for the platform 'nodejs' in the repo.\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version 10 -i /tmp/8d856447f4292 -p compress_node_modules=tar-gz --log-file /tmp/build-debug.log 
4:49:20 pm ppdedsrftwu2-appservice1: Deployment failed.

Have defined all the necessary settings in the portal.

SCM_DO_BUILD_DURING_DEPLOYMENT=true
WEBSITE_NODE_DEFAULT_VERSION=12
WEBSITES_PORT=3000
WEBSITE_HTTPLOGGING_RETENTION_DAYS=7

Tried with node version 10 also but still the same error.

Upvotes: 25

Views: 20971

Answers (7)

Vijay
Vijay

Reputation: 97

Adding to the other answers, it got fixed for me without updating portal settings,

  1. Deleted .vscode folder.
  2. Closed and reopened VS code.
  3. Clicked on "No" in the below popup which usually appears when I deploy from vscode(prviously clicked "Yes" and it resulted in an error posted here).

enter image description here

Upvotes: 0

I had the same issue. Just change settings on Azure to allow FTP Basic Auth Publishing Credentials, and everything run smoothly!

path> my web app>Settings>Configuration

Was checking it only to test, and worked.

Upvotes: 0

Mike Gledhill
Mike Gledhill

Reputation: 29213

I really don't understand why this bug is happening.

1:49:31 PM mikesapp: Detecting platforms...
1:49:31 PM mikesapp: Could not detect any platform in the source directory.
1:49:31 PM mikesapp: Error: Couldn't detect a version for the platform 'nodejs' in the repo.

I actually used Microsoft's own Azure App Service extension for VS Code to create my new Azure Web App, and to deploy my Angular app to the web service... but without the following steps it refused to deploy properly.

  1. Log into the Azure Portal, and go into your Web App

  2. In the left hand panel, select Settings \ Configuration

  3. Under the "Application Settings" tab, either create a brand new setting of "SCM_DO_BUILD_DURING_DEPLOYMENT" with the value false... or change the existing value to false.

  4. Under the "General Settings" tab, cut'n'paste this into the Startup Command textbox:

    pm2 serve /home/site/wwwroot --no-daemon --spa

  5. Click on the "Save" button

  6. Try to deploy your app from VS Code again

Seriously, I have no idea why Microsoft's own extension creates a Web App in a state which isn't ready to be deployed to (and throws an obscure error message when you use their extension to deploy to Azure).

Hope this helps.

Upvotes: 3

Anubis77
Anubis77

Reputation: 142

I also struggled with this issue.

Two things helped me :

When deploying from the Azure App service extension :

  1. Understanding that your root NodeJS application folder must be the root folder that is open in your explorer in vscode.

If your NodeJS application is in a subfolder, azure wont be able to build ( or identify your node platform : hence the error message that you are seeing ) the scripts in your root folder.

By far the easiest way to resolve this is to open vscode in the root folder ( the folder where your package.json file is located.

  • Also : When you click the deploy button on your vscode Azure App service extension : it might allow you to specify the folder to be deployed.

Deploy button location

  1. You can try to add the Application setting : SCM_DO_BUILD_DURING_DEPLOYMENT with the value of FALSE and Deployment slot setting of unchecked.

This is on the azure portal under configuration - application settings - add +

Remember to click that save button after adding new application settings ..... because azure ... lol.

But i think this is mostly way to delay your app building until the files are copied.

Last thing : If you are deploying from Github : Make sure that your nodeJS app is also in the root folder of the Github repo. If it is not you will need to update the workflow file to change the folder to the subfolder.

You just need to add cd yourfoldername above the line where it says npm install and commit the workflow change to the repo.

Hope this helps.

Upvotes: 4

Christian Matthew
Christian Matthew

Reputation: 4379

If you're doing a deployment from i.e., Visual Studio Code and deploying the dist/... folder then you wouldn't want to try and actually do a build hence setting SCM_DO_BUILD_DURING_DEPLOYMENT=false.

There is not a running node js server to actually do a build on the agent pool deployment pipeline. Azure devops or Jenkins per se would actually have an agent pool to do a "proper (air quotes)" build. Yes, you're code is running on node hence the setting you choose when setting up the web app. So those 2 things are not the same. Rather, DevOps.

I didn't find it in the documentation so appreciate the answer and responses here; but, I just wanted to give more context to the answer.

It's an upgrade to visual studio web apps deployment to potentially utilize other build methods like described in an answer here about github actions.

Upvotes: 1

osaru agbonaye
osaru agbonaye

Reputation: 97

In my case, I had the node app in a subdirectory, and this was causing this error in GitHub Actions job. Explicitly setting the working directory in the yml file fixed this. i.e

- name: npm install, build, and test
    working-directory: ./subdirectory
    run: |
      npm install
      npm run build --if-present
      npm run test --if-present

Upvotes: 2

Prateek Naik
Prateek Naik

Reputation: 2802

Connected with MS Support team they suggested to make the SCM_DO_BUILD_DURING_DEPLOYMENT= FALSE. After making this as false i am able to deploy the app. But the strange thing is with this option enabled i was doing earlier deployments and it was working.

Upvotes: 23

Related Questions