microsoft / vscode-azurestaticwebapps

Azure Static Web Apps extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurestaticwebapps
MIT License
86 stars 32 forks source link

Failed to very "AzureWebJobsStorage" error when debugging #868

Closed davidsk closed 6 months ago

davidsk commented 7 months ago

When I start the debugging session, I get the following error:

image

Frontend framework: Aurelia

Do you have a Functions API? Yes

What is your apps' file structure? Where does your frontend code live? Where does your API live? Not sure how much info you need here, swa and api are sibling folders, I had to drop the swa-cli.config.json at the workspace root before vscode could see it as a debug profile

-.vscode
- mobile
- api
swa-cli.config.json

Version information for: Functions Core Tools, Static Web Apps CLI, and Node.JS npm ls azure-functions-core-tools --global 4.0.5455

npm ls @azure/static-web-apps-cli --global 1.1.6

node --version 18.16.0

Did you try using a swa-cli.config.json file? If yes, please provide it. Yes, I did.

I started with

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "mobile": {
      "context":"http://localhost:10000",
      "run": "npm run start",
      "apiLocation": "http://localhost:7071"
    }
  }
}

and received the error shown above. I can run the swa+api using the following command line:

swa start http://localhost:10000 --api-location ../api --run "npm run start"

so I also tried the following config

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "mobile": {
      "context":"http://localhost:10000",
      "appLocation": "./mobile",
      "run": "npm run start",
      "apiLocation": "../api",
      "apiDevserverUrl": "http://localhost:7071"
    }
  }
}

but the error persists.

MicroFish91 commented 6 months ago

Do you happen to have the Azurite extension installed? This is likely coming from the Functions extension which is running the check via the Azurite extension

davidsk commented 6 months ago

I certainly do have the Azurite extension installed. I tried it again and this time selected the 'Debug anyway' option to see what would happen and it's a little weird.

When I run the app from the command line using the swa sdk I see this output in the terminal:

 mobile  swa start http://localhost:10000 --api-location ../api --run "npm run start"

Welcome to Azure Static Web Apps CLI (1.1.6)

***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure.                           *
***********************************************************************

[api] 
Azure Functions Core Tools
[api] Core Tools Version:       4.0.5455 Commit hash: N/A  (64-bit)
[api] Function Runtime Version: 4.27.5.21554
[api] 
[run] 
[run] > new-project-name@0.1.0 start
[run] > gulp
[run] 
[swa] 
[swa] Found configuration file:
[swa]   C:\Dev\srdavidson\mobile\staticwebapp.config.json
[swa]
[swa] - Waiting for http://localhost:10000 to be ready
[api] [2023-12-06T20:25:40.353Z] Worker process started and initialized.
[api] 
[api] Functions:
[api]
[api]   Addresses: [GET,POST,PATCH,DELETE] http://localhost:7071/api/addresses/{id?}
[api]
[api]   Customers: [GET,POST,PATCH,DELETE] http://localhost:7071/api/customers/{id?}
[api]
[api]   Engineers: [GET,POST,PATCH,DELETE] http://localhost:7071/api/engineers/{id?}
[api]
[api]   Jobs: [GET,POST,PATCH,DELETE] http://localhost:7071/api/jobs/{id?}
[api]
[api]   TimeDataCommand: [POST,PATCH,DELETE] http://localhost:7071/api/timeDataCommand/{id?}
[api]
[api]   TimeDataQuery: [GET] http://localhost:7071/api/timeDataQuery
[api]
[api] For detailed output, run func with --verbose flag.
[run] [dumber] Starting dumber bundler v2.1.1 https://dumber.js.org
[run] [20:25:42] Using gulpfile C:\Dev\srdavidson\mobile\gulpfile.js
[run] [20:25:42] Starting 'default'...
[run] [20:25:42] Starting 'clean'...
[run] [20:25:42] Finished 'clean' after 72 ms
[run] [20:25:42] Starting 'build'...
[run] [dumber] 2.0.0-beta.8 @aurelia/dialog
[run] [dumber] 2.0.0-beta.8 @aurelia/router
[run] [dumber] 2.0.0-beta.8 @aurelia/runtime-html
[run] [dumber] 2.0.0-beta.8 aurelia
[run] [dumber] 2.6.2      tslib
[run] [dumber] 2.0.0-beta.8 @aurelia/fetch-client
[run] [dumber] 2.0.0-beta.8 @aurelia/kernel
[run] [dumber] 2.0.0-beta.8 @aurelia/metadata
[run] [dumber] 2.0.0-beta.8 @aurelia/platform
[run] [dumber] 2.0.0-beta.8 @aurelia/platform-browser
[run] [dumber] 2.0.0-beta.8 @aurelia/route-recognizer
[run] [dumber] 2.0.0-beta.8 @aurelia/runtime
[run] [dumber] 2.1.1      dumber
[run] Update index.html with entry.bundle.js
[run] [20:25:46] Write app-bundle.js
[run] [20:25:46] Write entry.bundle.js
[run] [20:25:46] Finished 'build' after 4.71 s
[run] [20:25:46] Starting 'startServer'...
[run]
[run] Dev server is started at: http://localhost:10000
[run]
[run] [20:25:46] Finished 'startServer' after 7.36 ms
[run] [20:25:46] Starting 'watch'...
[swa] ✔ http://localhost:10000 validated successfully
[swa] - Waiting for http://localhost:7071 to be ready
[swa] ✔ http://localhost:7071 validated successfully
[swa] 
[swa] Using dev server for static content:
[swa]   http://localhost:10000
[swa]
[swa] Serving API:
[swa]   C:\Dev\srdavidson\api
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.

but when I use the debug launch profile I get this in a new terminal window

Terminal Window 1

*  Executing task: npm install 

up to date, audited 5 packages in 1s

found 0 vulnerabilities
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: func host start 

Azure Functions Core Tools
Core Tools Version:       4.0.5455 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.27.5.21554

[2023-12-06T20:26:50.011Z] Debugger listening on ws://127.0.0.1:9229/cd150cf1-0c5a-4af3-bba2-24b096113779
[2023-12-06T20:26:50.014Z] For help, see: https://nodejs.org/en/docs/inspector
[2023-12-06T20:26:50.016Z] Debugger attached.
[2023-12-06T20:26:50.246Z] Worker process started and initialized.
[2023-12-06T20:26:50.433Z] Debugger attached.

Functions:

        Addresses: [GET,POST,PATCH,DELETE] http://localhost:7071/api/addresses/{id?}

        Customers: [GET,POST,PATCH,DELETE] http://localhost:7071/api/customers/{id?}

        Engineers: [GET,POST,PATCH,DELETE] http://localhost:7071/api/engineers/{id?}

        Jobs: [GET,POST,PATCH,DELETE] http://localhost:7071/api/jobs/{id?}

        TimeDataCommand: [POST,PATCH,DELETE] http://localhost:7071/api/timeDataCommand/{id?}

        TimeDataQuery: [GET] http://localhost:7071/api/timeDataQuery

For detailed output, run func with --verbose flag.

and this in a second terminal window

Terminal Window 2

Welcome to Azure Static Web Apps CLI (1.1.6)

Using configuration "mobile" from file:
  swa-cli.config.json

***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure.                           *
***********************************************************************

[run] 
[run] > new-project-name@0.1.0 start
[run] > gulp
[run] 
[swa] 
[swa] Found configuration file:
[swa]   C:\Dev\srdavidson\mobile\staticwebapp.config.json
[swa] 
[swa] - Waiting for http://localhost:7071 to be ready    
[swa] ✔ http://localhost:7071 validated successfully
[swa] 
[swa] Serving static content:
[swa]   C:\Dev\srdavidson\mobile
[swa] 
[swa] Using dev server for API:
[swa]   http://localhost:7071
[swa] 
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.

at this point I get this dialog image

Terminal Window 2 (cont.)

[swa] 
[swa] 
[run] [dumber] Starting dumber bundler v2.1.1 https://dumber.js.org 
[run] [20:27:04] Using gulpfile C:\Dev\srdavidson\mobile\gulpfile.js
[run] [20:27:04] Starting 'default'...
[run] [20:27:04] Starting 'clean'...
[run] [20:27:04] Finished 'clean' after 42 ms
[run] [20:27:04] Starting 'build'...
[run] [dumber] 2.0.0-beta.8 @aurelia/dialog
[run] [dumber] 2.0.0-beta.8 @aurelia/router
[run] [dumber] 2.0.0-beta.8 @aurelia/runtime-html
[run] [dumber] 2.0.0-beta.8 aurelia
[run] [dumber] 2.6.2      tslib
[run] [dumber] 2.0.0-beta.8 @aurelia/fetch-client
[run] [dumber] 2.0.0-beta.8 @aurelia/kernel
[run] [dumber] 2.0.0-beta.8 @aurelia/metadata
[run] [dumber] 2.0.0-beta.8 @aurelia/platform
[run] [dumber] 2.0.0-beta.8 @aurelia/platform-browser
[run] [dumber] 2.0.0-beta.8 @aurelia/route-recognizer
[run] [dumber] 2.0.0-beta.8 @aurelia/runtime
[run] [dumber] 2.1.1      dumber
[run] Update index.html with entry.bundle.js
[run] [20:27:09] Write app-bundle.js
[run] [20:27:09] Write entry.bundle.js
[run] [20:27:09] Finished 'build' after 4.23 s
[run] [20:27:09] Starting 'startServer'...
[run]
[run] Dev server is started at: http://localhost:10000
[run]
[run] [20:27:09] Finished 'startServer' after 9.97 ms
[run] [20:27:09] Starting 'watch'...

Two things stand out about this:

Having said all that, I can debug the api but unsurprisingly, I cannot debug the spa code. The launch.json file looks okay as far as I can tell.

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Mobile",
            "request": "launch",
            "cwd": "${workspaceFolder}/mobile",
            "runtimeArgs": [
                "run-script",
                "start"
            ],
            "runtimeExecutable": "npm",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "node",
            "serverReadyAction":{
                "action": "debugWithEdge",
                "pattern": "Dev server is started at: ([0-9]+)",
                "uriFormat": "http://localhost:%s",
                "webRoot": "${workspaceFolder}/mobile",
                "killOnServerStop": false
            }
        },
        {
            "name": "Attach to Node Functions",
            "type": "node",
            "request": "attach",
            "port": 9229,
            "preLaunchTask": "func: host start",
            "cwd":"${workspaceFolder}/api"
        }
    ]
}
nturinski commented 6 months ago

This may be a dumb question, but the error makes me have to ask... Do you have Edge installed? I think the launch.json indicates that it's trying to debug using Edge.

AzCode-Bot commented 6 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!