microsoft / sample-app-aoai-chatGPT

Sample code for a simple web chat experience through Azure OpenAI, including Azure OpenAI On Your Data.
MIT License
1.57k stars 2.43k forks source link

Chat functionality not working after deploying web app to azure #603

Open VikashLalit opened 7 months ago

VikashLalit commented 7 months ago

Describe the bug

I have deployed the web app manually to azure from my local machine using az webapp up and also enabled authentication using Microsoft credentials for organisation but chat functionality is not working. Same is working fine in my local machine.

2024-02-09T14:08:08.110312833Z ERROR:root:Exception in send_chat_request

2024-02-09T14:08:08.116759508Z Traceback (most recent call last):

2024-02-09T14:08:08.116786910Z File "/tmp/xxxxxxx/antenv/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 115, in fail_after

2024-02-09T14:08:08.116793210Z yield cancel_scope

2024-02-09T14:08:08.116798111Z File "/tmp/xxxxxxxxxx/antenv/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp

2024-02-09T14:08:08.116803111Z stream: anyio.abc.ByteStream = await anyio.connect_tcp(

2024-02-09T14:08:08.116807811Z ^^^^^^^^^^^^^^^^^^^^^^^^

2024-02-09T14:08:08.116812412Z File "/tmp/xxxxxxxxx/antenv/lib/python3.11/site-packages/anyio/_core/_sockets.py", line 219, in connect_tcp

2024-02-09T14:08:08.116817412Z async with create_task_group() as tg:

2024-02-09T14:08:08.116822112Z File "/tmp/xxxxxxxxx/antenv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 688, in aexit

2024-02-09T14:08:08.116827013Z raise cancelled_exc_while_waiting_tasks

2024-02-09T14:08:08.116831513Z File "/tmp/xxxxxxxxxx/antenv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 668, in aexit

2024-02-09T14:08:08.116836113Z await asyncio.wait(self._tasks)

2024-02-09T14:08:08.116840714Z File "/opt/python/3.11.4/lib/python3.11/asyncio/tasks.py", line 418, in wait

2024-02-09T14:08:08.116845314Z return await _wait(fs, timeout, return_when, loop)

2024-02-09T14:08:08.116849814Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2024-02-09T14:08:08.116854415Z File "/opt/python/3.11.4/lib/python3.11/asyncio/tasks.py", line 525, in _wait

2024-02-09T14:08:08.116859315Z await waiter

2024-02-09T14:08:08.116863715Z asyncio.exceptions.CancelledError: Cancelled by cancel scope

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior chat functionality should work

Screenshots If applicable, add screenshots to help explain your problem.

Configuration: Please provide the following

Additional context Add any other context about the problem here.

sarah-widder commented 7 months ago

Hi @VikashLalit have you configured the app startup command on your app service to python3 -m gunicorn app:app ?

VikashLalit commented 7 months ago

Hi @sarah-widder , Yes i have already added this app start-up command in my app service configuration...

VikashLalit commented 7 months ago

Hi @sarah-widder , Can you please help with above mentioned issue

sarah-widder commented 7 months ago

@VikashLalit do you have any networking restrictions on your AOAI resource? Can you try using the Azure OpenAI portal and verify if you see the issue in the chat playground: https://oai.azure.com/portal You can also try to deploy an app from the playground and see if that one works.

VikashLalit commented 7 months ago

@sarah-widder All my azure resources including azure openai resource is configured to use selected network and private endpoint, also deployed web app is enabled to access from selected networks

For your question, one web app is already deployed using same azure openai resource and that is working fine.

sarah-widder commented 7 months ago

Are there any differences in configuration between your working app and the not working one? I would ensure that outbound network traffic from the app is configured to use the vnet so it can call the Azure OpenAI resource behind selected networks.

VikashLalit commented 7 months ago

@sarah-widder yes vnet is configured in my app service resource . but its fine right if my azure open ai resource is in different vnet and my app service is using different vnet ?

sarah-widder commented 7 months ago

@VikashLalit you would need to ensure that your web app is configured following these instructions: https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/use-your-data-securely#web-app

image