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 33 forks source link

Unable to debug Blazor app with function in WSL #871

Closed jhubsharp closed 5 months ago

jhubsharp commented 6 months ago

Frontend framework: Blazor (dotnet 8)

Do you have a Functions API? Yes, dotnet 8

What is your apps' file structure? Where does your frontend code live? Where does your API live? Blazor app lives in /app, Function lives in /api

Version information for: Functions Core Tools, Static Web Apps CLI, and Node.JS

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

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "special-orders": {
      "appLocation": "app",
      "apiLocation": "api",
      "outputLocation": "bin\\wwwroot",
      "apiLanguage": "dotnetisolated",
      "apiVersion": "8.0",
      "appBuildCommand": "dotnet publish -c Release -o bin",
      "apiBuildCommand": "dotnet publish -c Release",
      "run": "dotnet watch run",
      "appDevserverUrl": "http://localhost:5232"
    }
  }
}

package.json:

{
  "devDependencies": {
    "@azure/static-web-apps-cli": "^1.1.6"
  },
  "scripts": {
    "start": "swa start -o"
  }
}

I'm trying to run the CLI from within a WSL instance and debug the application. Using the provided config file I can run the app by using npm start with the included package.json so that I don't have to install the SWA CLI globally. For debugging, it looks like I have to install the CLI globally though.

When I run the debug command, two processes start: first the app runs the Functions host and binds to port 7071. Then, the SWA CLI runs and also tries to spin up a function on port 7071, whcih fails because the first process has bound the port. func start exits with code 1 and the SWA CLI waits forever to connect to the browser.

alexweininger commented 5 months ago

Could you provide the logs from the output channel when debugging?

You can try specifying the Functions API port to something different than 7071 by using the --api-port option.

See docs for swa start options

AzCode-Bot commented 5 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!