0

I am having a very difficult time trying to create a MS Azure hosted static web app from a Github repository.

The workflows seem to be failing.

Receiving these errors via email:

Azure Static Web Apps CI/CD / Close Pull Request Job Skipped
Azure Static Web Apps CI/CD / Build and Deploy Job Failed in 37 seconds

Errors:

Part 1:Detecting platforms... Detected following platforms: nodejs: 18.20.4 Version '18.20.4' of platform 'nodejs' is not installed. Generating script to install it... Error: Could not find either 'build' or 'build:azure' node under 'scripts' in package.json. Could not find value for custom run build command using the environment variable key 'RUN_BUILD_COMMAND'.Could not find tools for building monorepos, no 'lerna.json' or 'lage.config.js' files found.

Part 2:---End of Oryx build logs--- Oryx could not find a 'build' or 'build:azure' script in the package configuration. Please add one of these commands to your package configuration file (i.e. package.json). Alternatively, you can add the app_build_command to the build/deploy section of your workflow file. For example, app_build_command: 'npm run docs:build'

package.json:

{ 
"name": "vanilla-basic", 
"version": "1.0.0", 
"scripts": { "start": "sirv ./src public --cors --single --no-clear --port 8000" } 
}

I am running on a Mac and using the Safari Browser, if that even matters for this.

Appreciate any help.

Thanks!

13
  • could you share your workflow ? so it s github action not azure devops ? also what is the error you're seeing ? Commented Oct 29, 2024 at 0:44
  • It didn't seem to matter if you were using any browser in any OS, as the workflows were running on a remote agent. However, were you using GitHub actions or Azure DevOps pipelines for deployment? Can you share your YAML definition and detailed error messages in your original post? We don't know what to check if you don't share those details. Thx. Commented Oct 29, 2024 at 2:13
  • @user1104028 What framework is your app using, such as React, Blazor, or Next.js? Commented Oct 29, 2024 at 5:36
  • I seem to be receiving this error: Commented Oct 29, 2024 at 13:45
  • Part 1:Detecting platforms... Detected following platforms: nodejs: 18.20.4 Version '18.20.4' of platform 'nodejs' is not installed. Generating script to install it... Error: Could not find either 'build' or 'build:azure' node under 'scripts' in package.json. Could not find value for custom run build command using the environment variable key 'RUN_BUILD_COMMAND'.Could not find tools for building monorepos, no 'lerna.json' or 'lage.config.js' files found. Commented Oct 29, 2024 at 13:54

1 Answer 1

1

I created sample app with No Framework following this Ms Doc and deployed to Azure Static web app.

Detecting platforms... Detected following platforms: nodejs: 18.20.4 Version '18.20.4' of platform 'nodejs' is not installed. Generating script to install it... Error: Could not find either 'build' or 'build:azure' node under 'scripts' in package.json. Could not find value for custom run build command using the environment variable key 'RUN_BUILD_COMMAND'.Could not find tools for building monorepos, no 'lerna.json' or 'lage.config.js' files found. ---End of Oryx build logs--- Oryx could not find a 'build' or 'build:azure' script in the package configuration.

Even I got the same error, When I selected Build Presets : HTML Framework .

So, I changed the Build Presets : Custom as shown below.

enter image description here

GitHub Workflow File:


name: Azure Static Web Apps CI/CD
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main
jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
          lfs: false
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_FIELD_09FD45A10 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} 
          action: "upload"
          app_location: "./src" 
          api_location: ""
          output_location: "."   close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_FIELD_09FD45A10 }}
          action: "close"

Azure Static Web App Output:

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

@user1104028 Please check if the solution Above helped you. Let me know if there's anything else I can assist with.
Ok, that helped! But, I continued to receive errors that a version of nodejs was deprecated in the build/deploy errors. I noticed I had a package.json file, and that file seemed to be referencing nodejs. In this version of my game I was not using nodejs. So after I deleted both package.json and package-lock.json, the deployment worked!
When I got it to work, I had hanged the build preset to Custom. And I had set my source to "/" as that is where my source code is. I do not have my source code under "./src." And I did not use your .yml file, as the one Azure generate worked. I stopped experimenting after that.
@user1104028 So your source code is in the root directory, my code is in src, and package.json is in the root directory directory. When I set the app location to src, it worked. Actually, No-framework does not need a package.json; package.json is only useful for Node-based apps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.