Azure / Azure/static-web-apps-cli
Feedback on trying to deploy dotnet isolated API with static web app
- Dominant language
- TypeScript
- Stars
- 668
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
After hours of trying to figure out thing I just want to request some improvement with the dotnet isolated integration, it was really painful to get it working, due to the lack of error message or misleading error message.
I was not using github, I'm just using the cli in bash console on Linux (I just wanted to figure things out before setting up pipeline in Azure DevOps)
## Language is `dotnetisolated` and not `dotnet-isolated`
First things, the `--api-language` for `dotnet-isolated` function is... `dotnetisolated` (no dash) I spent so much time on it, getting the error message:
```
✖ Cannot deploy to the function app because Function language info isn't provided, use flags "--api-language" and "--api-version" or add a "platform.apiRuntime" property to your staticwebapp.config.json file, or create one in public. Please consult the documentation for more information about staticwebapp.config.json: https://learn.microsoft.com/azure/static-web-apps/build-configuration?tabs=github-actions#skip-building-the-api
```
I added to the `staticwebapp.config.json` the following, but it did not help (but the error message say it should...)
```
"platform": {
"apiRuntime": "dotnet-isolated:7.0"
},
```
Then I tried adding the `--api-version 7.0 --api-language dotnet-isolated` parameters and I was still getting the error message, I had to check the code to find this came from `StaticSitesClient` open this as text and find the json in it to finally see the string for the language is `dotnetisolated` and not `dotnet-isolated`

And if I try to put `dotnetisolated:7.0` in the config file I'm getting this error
```
The following error was encountered: must be equal to one of the allowed values dotnet:3.1, dotnet:6.0, dotnet-isolated:6.0, dotnet-isolated:7.0, node:12, node:14, node:16, node:18, python:3.8, python:3.9, python:3.10
0: {
1: "platform": {
2: "apiRuntime": "dotnetisolated:7.0"
3: },
```
So there is no easy way to figure out that the language should be `dotnetisolated` I think this may be a bug, but a tlease it would be nice in the error message to list the valid languages/versions.
---
## `swa build` / `swa deploy` was not publishing the api and is not deploying the correct folder
`swa build` was not building the dotnet app because there was noi `apiBuildCommand` in the `swa-cli.config.json` one improvement could be to add warning when there is an api location / `platform.apiRuntime` configured with no build command (at least for dotnet)
And when using the `swa deploy` I had to target the output folder in the `--api-location` instead of `./api` I has to add `./api/publish` (I'm using the build command `dotnet publish -c Release -o publish`)
---
That's all, I hope this can help to improve this product :) or at least it might help someone else trying to figure it out too in the future.
Contributor guide
Assessment
This issue has not been assessed yet.