Azure / Azure/static-web-apps-cli

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

オープン
#699 コメント 3 件 リアクション 5 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
668
フォーク
156
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, bash, typescript
領域
build-system, cli, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。