Open datkinson-mdvip opened 5 months ago
Any ideas on this one? I've tried multiple deployments with fresh repositories on both Mac and Windows/WSL. I've even had GitHub create the zip for me to deploy via az webapp deployment. I've tried it with SCM_DO_BUILD_DURING_DEPLOYMENT = true as well as = false with different results but ultimately resulting in a broken site. When I deploy with SCM_DO_BUILD_DURING_DEPLOYMENT= true, the deployment fails with this error:
Error: > Couldn't find any pages
or app
directory. Please create one under the project root
The only other thing that I've noticed is that the readme says the application uses Nextjs 13 but the package.json shows next version 14. I'm at a loss here trying to get this great application running anywhere other than my local machine.
Same Issue over here - seems to be a App Service Topic.
Have you managed to solve this issue? Any recommendations?
Yes, the solution is in the article 😅
you have to change the start command:
"start": "node_modules/nuxt/bin/nuxt.js start",
Currently doing az webapp deployment source config-zip
with SCM_DO_BUILD_DURING_DEPLOYMENT=false
.
Package.json is as follows, changed according to the article from "start": "next start"
to this:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "node_modules/next/dist/bin/next start",
"lint": "next lint"
},
Having the Startup Command on the web app to node_modules/next/dist/bin/next start
will result in this:
PATH="$PATH:/home/site/wwwroot" node_modules/next/dist/bin/next start
/opt/startup/startup.sh: 11: node_modules/next/dist/bin/next: not found
If I change the Startup Command to the initial next start
will get this:
PATH="$PATH:/home/site/wwwroot" next start
/opt/startup/startup.sh: 11: next: not found
Also seen on the yaml for the GitHub deployment workflow on the project to change the Startup Command to node server.js
, but that also doesn't work:
PATH="$PATH:/home/site/wwwroot" node server.js
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module '/home/site/wwwroot/server.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
For us, this works:
on:
push:
branches:
- main
env:
AZURE_WEBAPP_NAME: openai-app-main # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: './src' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '20.x' # set this to the node version to use
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: npm install, build, and test
run: |
cd ./src
npm install
npm run build --if-present
npm run test --if-present
cd ..
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: .
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: 'Deploy to Azure WebApp'
id: deploy-to-webapp
uses: azure/webapps-deploy@XXX
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
With:
"start": "node_modules/next/dist/bin/next start",
Maybe u can use something of it
Sorry for the late reply but I've moved on from this issue, we convinced our admin to allow GitHub deployments via SPN and the deployment worked as expected. There may still be an issue for manual deployments but it no longer applies to my situation.
My environment is very secure and I cannot deploy via GitHub actions. Nor am I able to deploy via Azd so I created the web app and Cosmos DB manually. I am able to successfully run the app locally just fine but I am unable to successfully deploy the app manually via az webapp deployment.
On an Apple silicon macbook, I followed instructions outlined in Issue https://github.com/microsoft/azurechat/issues/96 but the app does not start. When starting the service and watching the log stream, I see the following:
2024-01-11T18:48:28.972694974Z Running #!/bin/sh 2024-01-11T18:48:28.972728175Z 2024-01-11T18:48:28.972733775Z # Enter the source directory to make sure the script runs where the user expects 2024-01-11T18:48:28.972746275Z cd "/home/site/wwwroot" 2024-01-11T18:48:28.972756975Z 2024-01-11T18:48:28.972761175Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH 2024-01-11T18:48:28.972764875Z if [ -z "$PORT" ]; then 2024-01-11T18:48:28.972768575Z export PORT=8080 2024-01-11T18:48:28.972772575Z fi 2024-01-11T18:48:28.972775875Z 2024-01-11T18:48:28.972796775Z npm start 2024-01-11T18:48:38.915709407Z npm info using npm@9.6.4 2024-01-11T18:48:38.915753907Z npm info using node@v18.17.1 2024-01-11T18:48:39.032387464Z 2024-01-11T18:48:39.032425264Z > azure-open-ai-accelerator@1.2.0 start 2024-01-11T18:48:39.032431064Z > next start 2024-01-11T18:48:39.032434364Z 2024-01-11T18:48:39.101075986Z sh: 1: next: not found