Azure / Azure/static-web-apps-cli

Feedback on trying to deploy dotnet isolated API with static web app

Aperta
#699 3 commenti 5 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
668
Fork
156
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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`

![image](https://github.com/Azure/static-web-apps-cli/assets/539620/6e035e04-05bd-41ee-bdf5-c3ae2ae0b78c)

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the swa build and swa deploy entry points and the StaticSitesClient behavior referenced in the report. Review how apiBuildCommand, --api-language, --api-version, --api-location, and platform.apiRuntime are handled in swa-cli.config.json and staticwebapp.config.json. Done means valid runtime values are discoverable, missing API build configuration is reported, and the published API folder is handled consistently.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, bash, typescript
Ambito
build-system, cli, cloud
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.