Azure / Azure/static-web-apps-cli

swa deploy not working for streaming functions with python

Offen
#959 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
668
Forks
156
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

swa version: 2.0.6

**Are you accessing the CLI from the default port `:4280` ?**

- [ ] No, I am using a different port number (`--port`) and accessing the CLI from that port
- [x] Yes, I am accessing the CLI from port `:4280`

**Describe the bug**
The [official and GA way](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python-v2%2Cisolated-process%2Cnodejs-v4%2Cfunctionsv2&pivots=programming-language-python#example) to use streaming in python functions is to use the [azurefunctions-extensions-http-fastapi](https://pypi.org/project/azurefunctions-extensions-http-fastapi/) package.

Unfortunately when putting the following line into a `function_app.py` file

```python
from azurefunctions.extensions.http.fastapi import Request, StreamingResponse
```

and then running `swa deploy` results in the managed function not being deployed anymore. It works flawlessly when i remove the above line from the python file.

This issue **does not exist** when using the `AzureStaticWebApp@0` task in Azure DevOps. With this deployment task, both variants work.

```yaml
- task: AzureStaticWebApp@0
inputs:
app_location: 'site'
output_location: '.'
api_location: 'api'
azure_static_web_apps_api_token: $(apiKey)
config_file_location: '.'
```

**To Reproduce**
Steps to reproduce the behavior:

1. Clone [this swa-deploy-issue repository](https://github.com/fabge/swa-deploy-issue)
2. Type in command `swa deploy` and watch it deploy the site + managed api correctly
3. Insert `from azurefunctions.extensions.http.fastapi import Request, StreamingResponse` into `src/functionapp`
4. Type in command `swa deploy` and watch it deploy the site but without any managed api

**Expected behavior**
I expect `swa deploy` to work with the official python streaming manual.

**Additional context**
I have attached both verbose logs of the deployments.

[broken-swa-deploy.txt](https://github.com/user-attachments/files/20575074/broken-swa-deploy.txt)
[working-swa-deploy.txt](https://github.com/user-attachments/files/20575073/working-swa-deploy.txt)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem verlinkten swa-deploy-issue-Reproduktionsrepository und vergleiche verbose broken-swa-deploy.txt mit working-swa-deploy.txt. Reproduziere `swa deploy` mit und ohne den Import `azurefunctions.extensions.http.fastapi` in `function_app.py` und vergleiche diesen Pfad anschließend mit der funktionierenden AzureStaticWebApp@0-Aufgabe. Als erledigt gilt die Aufgabe, wenn die verwaltete API bereitgestellt wird, sobald der offizielle Python-Streaming-Import vorhanden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
backend, cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.