Closed siddharth-krishna closed 2 years ago
Hi. I've been trying to replicate the issue on my WSL environment but with no luck.
/home/damauri/.nvm/versions/node/v14.19.0/lib
├── @azure/static-web-apps-cli@1.0.2
├── azure-functions-core-tools@4.0.4670
Can you just try to see if the SWA cli work as expected by following this sample procedure:
1) create an empty folder, for example test-app
2) in the test-app
folder create two folders: client
and api
3) move into the api
folder and run func init --worker-runtime dotnet
to initialize the azure function environment
4) always from the api
folder run func new --language c# --template HttpTrigger --name DemoFunction
to create a sample function with an HttpTrigger
5) go back to test-app
folder and run swa start ./client --api-location ./api
You should see something similar to:
Welcome to Azure Static Web Apps CLI (1.0.2)
***********************************************************************
* WARNING: This emulator may not match the cloud environment exactly. *
* Always deploy and test your app in Azure. *
***********************************************************************
[swa] - Waiting for http://localhost:7071 to be ready
[api] Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
[api] Copyright (C) Microsoft Corporation. All rights reserved.
[api]
[api] Determining projects to restore...
[api] Restored /home/damauri/sandbox/test-app/api/api.csproj (in 689 ms).
[api] api -> /home/damauri/sandbox/test-app/api/bin/output/api.dll
[api]
[api] Build succeeded.
[api] 0 Warning(s)
[api] 0 Error(s)
[api]
[api] Time Elapsed 00:00:03.02
[api]
[api]
[api]
[api] Azure Functions Core Tools
[api] Core Tools Version: 4.0.4544 Commit hash: N/A (64-bit)
[api] Function Runtime Version: 4.3.2.18186
[api]
[api] [2022-08-05T18:34:26.679Z] Found /home/damauri/sandbox/test-app/api/api.csproj. Using for user secrets file configuration.
[api]
[api] Functions:
[api]
[api] DemoFunction: [GET,POST] http://localhost:7071/api/DemoFunction
[api]
[api] For detailed output, run func with --verbose flag.
[swa] ✔ Connected to http://localhost:7071 successfully
[swa]
[swa] Serving static content:
[swa] /home/damauri/sandbox/test-app/client
[swa]
[swa] Serving API:
[swa] /home/damauri/sandbox/test-app/api
[swa]
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
[swa]
[swa]
The important part is the Connected to http://localhost:7071 successfully
If you cannot see this (as it happens in the log you have pasted before` there must be something wrong with SWA and Azure Function integration. I'll try on my Mac later too.
Thank you for the quick response! I figured out the issue, apologies for any inconvenience: I had another VS Code window open in the background that had https://github.com/Azure/azure-functions-sql-extension/tree/main/samples/samples-python open in a dev container which was automatically forwarding port 7071. So I guess func
was unable to attach to that port (strange that it didn't complain about this, perhaps it was spinning waiting for the port to be ready?).
Once I removed that port forward, I was able to see the missing lines:
[swa] - Waiting for http://localhost:7071 to be ready
Connected to http://localhost:7071 successfully
and
[swa] Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
Thanks! Why do we need Azurite btw? The Az Fn is fetching and storing data from the remote SQL server even in local dev. So I don't think we need any local storage?
Great. AFAIK Azure Functions needs to store metadata into an Azure Storage account, that's why the need for Azurite...It might well be that the last version of SWA are also taking care of that part too, so maybe Azurite it not needed anymore. I'll check as soon as I'll push some updates to the repo (in the next weeks)
@yorek thanks for an awesome talk and really helpful code & scripts. Unfortunately, I wasn't able to get this app running on local dev. My
swa start
command just never prints theAzure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to exit.
line:I have followed all the instructions above, installed dependencies, created a SQL server, deployed the databases, and am running Azurite via the VS Code extention (why is this needed btw?). I also tried the
1.0
tag, which has the same issue. If I runswa start ./client
(without the--api-location
flag), it serves the app, but of course it cannot connect to the backend. Any idea what I'm missing?My setup: OS: macOS 12.5 Node version: 16.16.0