I build and deploy my static web app withou error via GitHub actions (workflow and log below). In Azure, the Production environment statis is ready and the webapp/front-end works, but fails/throws error when it calls an API. The APIs/managed functions are not deployed correctly. SWA portal / API's blade shows no APIs. Application Insights blade displays message: "App Insights is only applicable to Static Web Apps with at least one function. Add a function to your app to enable App Insights." The SWA Metrics blade shows FunctionErrors when my front-end calls the APIs...but neither SWA portal nor Azure CLI provide an option to access the error details for these managed functions. I'm using NPM version 18 instead of 20. Debug step I added in build shows all the correct function files in the api/dist location.
BUILD AND DEPLOY WORKFLOW:
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
env:
NPM_CONFIG_INSTALL_LINKS: "false"
ORYX_LOGGING_LEVEL: trace
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_MEADOW_0C266860F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "App" # App source code path
api_location: "api" # Api source code path - optional
output_location: "dist" # Built app content directory - optional
api_build_command: |
npm run build
ls -R dist
app_build_command: "npm run build"
###### End of Repository/Build Configurations ######
BUILD AND DEPLOY LOG
Run Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ***
repo_token: ***
action: upload
app_location: App
api_location: api
output_location: dist
api_build_command: npm run build
ls -R dist
app_build_command: npm run build
env:
NPM_CONFIG_INSTALL_LINKS: false
ORYX_LOGGING_LEVEL: trace
/usr/bin/docker run --name b157fdb34d5b7abc904b56adf03fe07239de8f_8a4adc --label b157fd --workdir /github/workspace --rm -e "NPM_CONFIG_INSTALL_LINKS" -e "ORYX_LOGGING_LEVEL" -e "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_REPO_TOKEN" -e "INPUT_ACTION" -e "INPUT_APP_LOCATION" -e "INPUT_API_LOCATION" -e "INPUT_OUTPUT_LOCATION" -e "INPUT_API_BUILD_COMMAND" -e "INPUT_APP_BUILD_COMMAND" -e "INPUT_APP_ARTIFACT_LOCATION" -e "INPUT_ROUTES_LOCATION" -e "INPUT_SKIP_APP_BUILD" -e "INPUT_CONFIG_FILE_LOCATION" -e "INPUT_SKIP_API_BUILD" -e "INPUT_PRODUCTION_BRANCH" -e "INPUT_DEPLOYMENT_ENVIRONMENT" -e "INPUT_IS_STATIC_EXPORT" -e "INPUT_DATA_API_LOCATION" -e "INPUT_GITHUB_ID_TOKEN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/TrainingBot/TrainingBot":"/github/workspace" b157fd:b34d5b7abc904b56adf03fe07239de8f
DeploymentId: ed3b8dda-66ca-4d15-bf50-147ac2b5e146
Try to validate location at: '/github/workspace/App'.
App Directory Location: 'App' was found.
Try to validate location at: '/github/workspace/swa-db-connections'.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
Oryx will build app with the following custom override command: npm run build
---Oryx build logs---
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version: 0.2.20250107.1+ef3fb2f9c490a4fbb1f76b5746cd4ba2ff0409f4, Commit: ef3fb2f9c490a4fbb1f76b5746cd4ba2ff0409f4, ReleaseTagName: 20250107.1
Build Operation ID: e1667c71258b4fad
OS Type : bullseye
Image Type : githubactions
Detecting platforms...
Detected following platforms:
nodejs: 18.20.8
Version '18.20.8' of platform 'nodejs' is not installed. Generating script to install it...
Detected the following frameworks: Typescript,React
Source directory : /github/workspace/App
Destination directory: /bin/staticsites/ed3b8dda-66ca-4d15-bf50-147ac2b5e146-swa-oryx/app
Downloading and extracting 'nodejs' version '18.20.8' to '/tmp/oryx/platforms/nodejs/18.20.8'...
npm run vendor-contracts && tsc -p tsconfig.json && node scripts/copy-config.js
api@0.1.0 vendor-contracts
node scripts/vendor-contracts.js
[vendor-contracts] Copied @trainingbot/contracts into the Functions node_modules.
dist:
agent-scenarios
chat-sessions
config
host.json
index.js
metadata
shared
users
dist/agent-scenarios:
delete.js
index.js
publish.js
update.js
dist/chat-sessions:
index.js
dist/config:
app-settings.devtest.json
evaluation_prompt_template.txt
simulation_prompt_template.txt
validAIModels.txt
dist/metadata:
models.js
prompt-template.js
dist/shared:
aiFoundry.js
auth.js
config.js
cosmos.js
http.js
storage.js
dist/users:
index.js
Copy '/github/workspace/api/node_modules' with all dependencies to '/github/workspace/api/.oryx_all_node_modules'...
Copying production dependencies from '/github/workspace/api/.oryx_prod_node_modules/node_modules' to '/github/workspace/api/node_modules'...
Preparing output...
Copying files to destination directory '/bin/staticsites/ed3b8dda-66ca-4d15-bf50-147ac2b5e146-swa-oryx/api'...
Done in 2 sec(s).
Removing existing manifest file
Creating a manifest file...
Manifest file created.
Copying .ostype to manifest output directory.
Done in 33 sec(s).
---End of Oryx build logs---
Function Runtime Information. OS: linux, Functions Runtime: ~4, node version: 18
Finished building function app with Oryx
Zipping Api Artifacts
Done Zipping Api Artifacts
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.1553855(s)
Status: InProgress. Time: 15.306633(s)
Status: Succeeded. Time: 34.4210467(s)
Deployment Complete :)
Visit your site at: https://lively-meadow-0c266860f.3.azurestaticapps.net
Thanks for using Azure Static Web Apps!
Exiting