static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

Deploy without build or api fails with "An unknown exception has occurred"

Open eeisenbr opened this issue 2 years ago • 2 comments

Describe the bug Deploying a pre-built React-based app fails with "An unknown exception has occurred". The last console message written is "Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored." Normally the next message is "No Api directory specified. Azure Functions will not be created." This problem only happens when running on MS-hosted ADO agents (ubuntu-latest), I can't get it to happen when running locally.

To Reproduce Steps to reproduce the behavior:

Build a React app (in our case, using Create React App, running npm run build). Include staticwebapp.config.json. Ours just has typical React routing info. Then attempt to deploy as follows:

$token = az staticwebapp secrets list --name "$(azureResourceNames.StaticWebApp)" --query "properties.apiKey" | ConvertFrom-Json
swa deploy --app-location "$(System.DefaultWorkingDirectory)/app" --deployment-token "$token" --env Production --verbose silly

Here are the resulting logs:

2023-02-13T21:59:33.8344217Z 
2023-02-13T21:59:33.8345497Z Welcome to Azure Static Web Apps CLI (1.0.6)
2023-02-13T21:59:33.8345987Z 
2023-02-13T21:59:33.8444803Z Getting config file options from swa-cli.config.json...
2023-02-13T21:59:33.8460991Z Config file does not exist at /home/vsts/work/r1/a/swa-cli.config.json
2023-02-13T21:59:33.8573099Z Deploying front-end files from folder:
2023-02-13T21:59:33.8589940Z   /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8604395Z 
2023-02-13T21:59:33.8630420Z Deployment token provided via flag
2023-02-13T21:59:33.8648446Z  - --deployment-token: <hidden>
2023-02-13T21:59:33.8662537Z 
2023-02-13T21:59:33.8663320Z Deploying to environment: Production
2023-02-13T21:59:33.8663546Z 
2023-02-13T21:59:33.8683631Z Trying to read workflow config with values:
2023-02-13T21:59:33.8701640Z  - appLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8702101Z  - outputLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8704965Z  - apiLocation: <undefined>
2023-02-13T21:59:33.8724205Z No workflow config folder found at /home/vsts/work/r1/a/app/.github/workflows
2023-02-13T21:59:33.8740076Z Validating user workflow config (BEFORE):
2023-02-13T21:59:33.8756401Z  - appLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8757107Z  - outputLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8757971Z  - apiLocation: <undefined>
2023-02-13T21:59:33.8772244Z Validating user workflow config (AFTER):
2023-02-13T21:59:33.8788555Z  - appLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.8789206Z  - apiLocation: <undefined>
2023-02-13T21:59:33.8789800Z  - outputLocation: /home/vsts/work/r1/a/app
2023-02-13T21:59:33.9629669Z Loading staticwebapp.config.json schema...
2023-02-13T21:59:34.5038684Z Schema loaded successfully from https://json.schemastore.org/staticwebapp.config.json
2023-02-13T21:59:34.5075982Z Compiling schema...
2023-02-13T21:59:34.5797983Z Reading content from staticwebapp.config.json...
2023-02-13T21:59:34.5852584Z Parsing staticwebapp.config.json...
2023-02-13T21:59:34.5867556Z Validating staticwebapp.config.json...
2023-02-13T21:59:34.5910268Z File validated successfully. Continuing with configuration!
2023-02-13T21:59:34.5929487Z Content parsed successfully
2023-02-13T21:59:34.5944292Z 
2023-02-13T21:59:34.5944891Z Found configuration file:
2023-02-13T21:59:34.5945412Z   /home/vsts/work/r1/a/app/staticwebapp.config.json
2023-02-13T21:59:34.5945777Z 
2023-02-13T21:59:34.5960110Z Deploying project to Azure Static Web Apps...
2023-02-13T21:59:34.5977530Z Could not find StaticSitesClient local binary
2023-02-13T21:59:34.6008571Z Fetching release metadata for version: stable. Please wait...
2023-02-13T21:59:34.8447820Z  - version: stable
2023-02-13T21:59:34.8449128Z  - buildId: 1.0.022152
2023-02-13T21:59:34.8449863Z  - publishDate: 2023-01-24T18:38:40.5584174Z
2023-02-13T21:59:34.8450575Z - files:
2023-02-13T21:59:34.8451104Z  - linux-x64:
2023-02-13T21:59:34.8451960Z    - url: https://swalocaldeploy.azureedge.net/downloads/1.0.022152/linux/StaticSitesClient
2023-02-13T21:59:34.8452936Z    - sha: 40e1639efc239151b3021a262ee85a747403fbf1c9ffce3de1aa0cbf273a3069
2023-02-13T21:59:34.8453741Z  - win-x64:
2023-02-13T21:59:34.8454589Z    - url: https://swalocaldeploy.azureedge.net/downloads/1.0.022152/windows/StaticSitesClient.exe
2023-02-13T21:59:34.8455544Z    - sha: e3287b8b63b00faa501573cd205ce8f7bb9743f7107f3e4f01639d0b297f21fc
2023-02-13T21:59:34.8456187Z  - osx-x64:
2023-02-13T21:59:34.8456983Z    - url: https://swalocaldeploy.azureedge.net/downloads/1.0.022152/macOS/StaticSitesClient
2023-02-13T21:59:34.8457916Z    - sha: 396f5fefe087399c78521b2f5456c79e58c771ca64785e4be055a149738a2e6a
2023-02-13T21:59:34.8473801Z - Downloading https://swalocaldeploy.azureedge.net/downloads/1.0.022152/linux/[email protected]
2023-02-13T21:59:35.7375417Z [swa] ✔ Downloading https://swalocaldeploy.azureedge.net/downloads/1.0.022152/linux/[email protected]
2023-02-13T21:59:35.7392343Z Checksum match: 40e1639efc239151b3021a262ee85a747403fbf1c9ffce3de1aa0cbf273a3069
2023-02-13T21:59:35.7445463Z Saved binary to /home/vsts/.swa/deploy/1.0.022152/StaticSitesClient
2023-02-13T21:59:35.7464911Z Saved metadata to /home/vsts/.swa/deploy/StaticSitesClient.json
2023-02-13T21:59:35.7492858Z Deploying using /home/vsts/.swa/deploy/1.0.022152/[email protected]
2023-02-13T21:59:35.7502117Z Deploying using the following options:
2023-02-13T21:59:35.7516973Z - env:
2023-02-13T21:59:35.7517595Z   - SWA_CLI_DEBUG: silly
2023-02-13T21:59:35.7518275Z   - SWA_RUNTIME_WORKFLOW_LOCATION: <undefined>
2023-02-13T21:59:35.7519026Z   - SWA_RUNTIME_CONFIG_LOCATION: /home/vsts/work/r1/a/app
2023-02-13T21:59:35.7519878Z   - SWA_RUNTIME_CONFIG: /home/vsts/work/r1/a/app/staticwebapp.config.json
2023-02-13T21:59:35.7520423Z   - SWA_CLI_VERSION: 1.0.6
2023-02-13T21:59:35.7520964Z   - SWA_CLI_DEPLOY_DRY_RUN: false
2023-02-13T21:59:35.7522710Z   - SWA_CLI_DEPLOY_BINARY: /home/vsts/.swa/deploy/1.0.022152/[email protected]
2023-02-13T21:59:35.7523343Z   - DEPLOYMENT_ACTION: upload
2023-02-13T21:59:35.7523876Z   - DEPLOYMENT_PROVIDER: SwaCli
2023-02-13T21:59:35.7524412Z   - REPOSITORY_BASE: /home/vsts/work/r1/a/app
2023-02-13T21:59:35.7524949Z   - SKIP_APP_BUILD: true
2023-02-13T21:59:35.7525445Z   - SKIP_API_BUILD: true
2023-02-13T21:59:35.7525910Z   - DEPLOYMENT_TOKEN: <hidden>
2023-02-13T21:59:35.7526545Z   - APP_LOCATION: /home/vsts/work/r1/a/app
2023-02-13T21:59:35.7527082Z   - API_LOCATION: <undefined>
2023-02-13T21:59:35.7527601Z   - CONFIG_FILE_LOCATION: /home/vsts/work/r1/a/app
2023-02-13T21:59:35.7528128Z   - VERBOSE: true
2023-02-13T21:59:35.7528713Z - Preparing deployment. Please wait...
2023-02-13T21:59:35.8128091Z ℹ DeploymentId: 5330c4d5-a746-4856-b9fe-b1e5c8a1747e
2023-02-13T21:59:35.8128825Z ℹ Preparing deployment. Please wait...
2023-02-13T21:59:35.9158310Z ℹ [37mVerbose logging enabled[0m
2023-02-13T21:59:35.9560268Z ℹ [37mBuild timeout not specified, defaulting to 15 minutes[0m
2023-02-13T21:59:35.9561621Z ℹ [37mApp Directory Location: '/home/vsts/work/r1/a/app' was found.[0m
2023-02-13T21:59:35.9562589Z ℹ [37mconfig_file_location: config file '/home/vsts/work/r1/a/app/staticwebapp.config.json' was found.[0m
2023-02-13T21:59:35.9567409Z ℹ [37mLooking for event info[0m
2023-02-13T21:59:35.9568563Z ℹ [37mCould not get event info. Proceeding[0m
2023-02-13T21:59:36.8248104Z ℹ [37mSkipping step to build /home/vsts/work/r1/a/app with Oryx[0m
2023-02-13T21:59:36.8257412Z ℹ [37mDidn't find Oryx manifest file under location: /home/vsts/work/r1/a/5330c4d5-a746-4856-b9fe-b1e5c8a1747e-swa-oryx/app-manifest/oryx-manifest.toml[0m
2023-02-13T21:59:36.8258949Z ℹ [37mDetermined default file to be: index.html[0m
2023-02-13T21:59:36.8259825Z ℹ [37mUsing 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.[0m
2023-02-13T21:59:36.8260576Z ✖ [31mAn unknown exception has occurred[0m
2023-02-13T21:59:36.8292302Z ℹ [37m[0m
2023-02-13T21:59:36.8313285Z ℹ [33mFor further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/[0m
2023-02-13T21:59:36.8315370Z ℹ [33mIf you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/[0m

Expected behavior The app is successfully deployed

Desktop (please complete the following information): https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md

Additional context This does not happen on my local machine (Windows 10) following the same steps.

eeisenbr avatar Feb 13 '23 22:02 eeisenbr

@eeisenbr just to confirm, are you able to deploy from your local machine using SWA_CLI?

sgollapudi77 avatar Feb 14 '23 06:02 sgollapudi77

@sgollapudi77 yes, deploying from my local machine works (same versions of everything except Linux vs Windows).

eeisenbr avatar Feb 14 '23 14:02 eeisenbr