Azure / Azure/static-web-apps-cli

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

Abierto
#699 3 comentarios 5 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
668
Forks
156
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
azure, bash, typescript
Área
build-system, cli, cloud
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.