static-web-apps-cli: swa deploy hangs at "Preparing deployment. Please wait"

Describe the bug

When running:

npx swa deploy --no-use-keychain -d {deployment-token}

It hangs on Preparing deployment. Please wait...

Full output is (with --verbose=silly):

Welcome to Azure Static Web Apps CLI (1.0.3)

Getting config file options from swa-cli.config.json...
Changed directory to /folder
Using configuration "qwik-app" from file:
  /folder/swa-cli.config.json

Deploying front-end files from folder:
  /folder/dist

Deploying API from folder:
  /folder/dist

Deployment token provided via flag
 - --deployment-token: <hidden>

Deploying to environment: preview

Trying to read workflow config with values:
 - appLocation: /folder/dist
 - outputLocation: /folder/dist
 - apiLocation: /folder/dist
No workflow config folder found at /folder/dist/.github/workflows
Validating user workflow config (BEFORE):
 - appLocation: /folder/dist
 - outputLocation: /folder/dist
 - apiLocation: /folder/dist
Validating user workflow config (AFTER):
 - appLocation: /folder/dist
 - apiLocation: /folder/dist
 - outputLocation: /folder/dist
Loading staticwebapp.config.json schema...
Schema loaded successfully from https://json.schemastore.org/staticwebapp.config.json
Compiling schema...
Reading content from staticwebapp.config.json...
Parsing staticwebapp.config.json...
Validating staticwebapp.config.json...
File validated successfully. Continuing with configuration!
Content parsed successfully

Found configuration file:
  /folder/dist/staticwebapp.config.json

Deploying project to Azure Static Web Apps...
Fetching release metadata for version: stable. Please wait...
 - version: stable
 - buildId: 1.0.020981
 - publishDate: 2022-09-29T17:37:34.4094014Z
- files:
 - linux-x64:
   - url: https://swalocaldeploy.azureedge.net/downloads/1.0.020981/linux/StaticSitesClient
   - sha: e55db21d0720a12098804559152303e66846bdd94c13a30b30be29a0fc9ae366
 - win-x64:
   - url: https://swalocaldeploy.azureedge.net/downloads/1.0.020981/windows/StaticSitesClient.exe
   - sha: 4e4eb72aef26641e236c24929c822500e956bda099ca78054112cadf20261107
 - osx-x64:
   - url: https://swalocaldeploy.azureedge.net/downloads/1.0.020981/macOS/StaticSitesClient
   - sha: e0f2ae7ec297510a1b3b9332c0dc0dd962a51adb8ea13cd4f3746d79fc24a7e9
Local client binary is up to date. Skipping download.
Deploying using /home/user/.swa/deploy/1.0.020981/StaticSitesClient@1.0.020981
Deploying using the following options:
- env:
  - SWA_CLI_DEBUG: silly
  - SWA_RUNTIME_WORKFLOW_LOCATION: <undefined>
  - SWA_RUNTIME_CONFIG_LOCATION: /folder/dist
  - SWA_RUNTIME_CONFIG: /folder/dist/staticwebapp.config.json
  - SWA_CLI_VERSION: 1.0.3
  - SWA_CLI_DEPLOY_DRY_RUN: false
  - SWA_CLI_DEPLOY_BINARY: /home/user/.swa/deploy/1.0.020981/StaticSitesClient@1.0.020981
  - DEPLOYMENT_ACTION: upload
  - DEPLOYMENT_PROVIDER: SwaCli
  - REPOSITORY_BASE: /folder/dist
  - SKIP_APP_BUILD: true
  - SKIP_API_BUILD: true
  - DEPLOYMENT_TOKEN: <hidden>
  - APP_LOCATION: /folder/dist
  - API_LOCATION: /folder/dist
  - CONFIG_FILE_LOCATION: /folder/dist
  - VERBOSE: true
  - DEPLOYMENT_ENVIRONMENT: preview
⠧ Preparing deployment. Please wait...

To Reproduce Steps to reproduce the behavior:

  1. Create a static webapp with API
  2. Create a swa-cli.config.json containing:
    {
      "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
      "configurations": {
        "qwik-app": {
          "appName": "qwik-app",
          "appLocation": "./dist",
          "apiLocation": "./dist",
          "appBuildCommand": "npm run build",
          "apiBuildCommand": "npm run build.server"
        }
      }
    }
    
  3. Run npx swa deploy --no-use-keychain -d {deployment-token}
  4. The deployment hangs on Preparing deployment. Please wait...

Expected behavior Deploy with swa CLI should work.

Desktop (please complete the following information):

  • OS: Windows
  • Version 11
  • WSL2: 1.0.0.0
  • WSL Distro: Ubuntu 22.10

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

This same problem happens when running swa in a dev container on an M1 Mac. It is incorrectly downloading an x86-64 binary.

It also may not be properly accounting for exit code 255.

❯ ~/.swa/deploy/1.0.023121/StaticSitesClient
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

Thanks! The swa deploy works now event without setting DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 and passing --no-use-keychain and it does not hang. So, this should be fixed.

However my app (https://github.com/derkoe/qwik-swa-demo) cannot be deployed anymore - this is the error:

✖ Current directory cannot be identical to or contained within artifact folders.

(guess I have to create another issue for that).


I still think that downloading the binary on deploy and then starting it is not a very good practice:

  1. This makes builds not reproducible - one time it fails, then it works, then it fails again. All with the same version of @azure/static-web-apps-cli
  2. From a security standpoint this is not a good idea

I guess it would be best to either implement the API calls directly in @azure/static-web-apps-cli or at least bundle the binary with the npm package.