Because of the permission issue when using the API build in the AzureStaticWebApp@0 task, I am skipping the API build and build it in an earlier task.
Here is my task:
- task: AzureStaticWebApp@0
inputs:
app_location: "/dist"
output_location: ""
skip_app_build: true
api_location: "/src/api/dist"
skip_api_build: true
verbose: true
azure_static_web_apps_api_token: "$(DeploymentToken)"
The build for the app works fine, but my api (Managed Function, node:18) is not recognized in the portal. It's not showing up. The build task for my Function looks like this:
- task: Npm@1
displayName: "Build command Api (function): npm --prefix api build --production"
inputs:
command: custom
verbose: false
customCommand: "run --prefix src/api build --production"
My dist folder, in the pipeline looks like this:
2025-01-13T15:46:12.7797380Z ├── src
2025-01-13T15:46:12.7797647Z │ ├── api
2025-01-13T15:46:12.7797785Z │ │ ├── dist
2025-01-13T15:46:12.7797937Z │ │ │ ├── functions
2025-01-13T15:46:12.7798106Z │ │ │ │ └── HealthCheck.js
2025-01-13T15:46:12.7798260Z │ │ │ ├── host.json
2025-01-13T15:46:12.7798407Z │ │ │ ├── index.js
2025-01-13T15:46:12.7798558Z │ │ │ └── package.json
Am I missing any files in the output folder? I think the package.json shouldn't be there but I added it, since it has some information about the 'main' method.
I added the following code to my staticwebappconfig.json, to set the language:
"platform": {
"apiRuntime": "node:18"
}
That part is picked up correctly by the pipeline. Locally the function works fine.
Update:
Output of the deployment task
Verbose logging enabled
Try to validate location at: '/working_dir/dist'.
Build timeout not specified, defaulting to 15 minutes
App Directory Location: '/dist' was found.
Try to validate location at: '/working_dir/swa-db-connections'.
Looking for event info
Event info parsed from action options.
Skipping step to build /working_dir/dist with Oryx
Found staticwebapp.config.json file: 'dist/staticwebapp.config.json'
Didn't find Oryx manifest file under location: /82f6534c-e4ab-4df9-a48f-7dafd19fb4c4-swa-oryx/app-manifest/oryx-manifest.toml
Determined default file to be: index.html
Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.
Calculating the size of app artifacts: 15791055 B
Try to validate location at: '/working_dir/src/api/dist'.
Api Directory Location: '/src/api/dist' was found.
Skipping step to build /working_dir/src/api/dist with Oryx
Function Runtime Information. OS: linux, Functions Runtime: ~4, node version: 18
Zipping Api Artifacts
Api Zip will be created from directory: /working_dir/src/api/dist
Api Content Hash: dd6cb5ae81d9fc366a150da4716132d0
Done Zipping Api Artifacts
Zipping App Artifacts
App Zip will be created from directory: /working_dir/dist
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0876904(s)
Status: InProgress. Time: 15.1317785(s)
Status: InProgress. Time: 30.1822736(s)
Status: Succeeded. Time: 45.228502(s)
Deployment Complete :)
Visit your site at: https://<our swa url>
Thanks for using Azure Static Web Apps!
Exiting
Finishing: AzureStaticWebApp