azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

how to connect multiple Frontend to a single backend which is present here?

Open thwayant opened this issue 1 year ago • 4 comments

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

Hi, what should i do to connect multiple frontend to this backend, each frontend is able to chat with its own data only, monitoring which frontend is using what amount of resources, and how would i deploy only the backend using azure?

Any help is greatly appreciated. Thanks!!

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

azd version?

run azd version and copy paste here.

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

thwayant avatar Jan 17 '24 10:01 thwayant

I suggest:

  • Store each frontend's data in a different index (you could also use search fields with filters, but if the data is different enough, I think a separate index makes sense).
  • Adding a mapping in the backend from frontend domain to search index, to make sure you send back data from the right index. You'll need to propagate that index to the approach files instead of configuring it globally, as it's done now.
  • Deploy frontends using Static Web Apps. https://github.com/Azure-Samples/azure-search-openai-javascript is already designed for deployment on SWA so you may want to use that, as it will be cheaper than running each frontend on App Service. You can also deploy this frontend to SWA or to separate App Service instances if preferred.

As for monitoring, this backend is already instrumented with OpenTelemetry, so you should see stats show up in Azure Monitor. You can filter the "requests" table per "url" column. For more advanced monitoring, consult the Application Insights docs.

You could also look into APIM as a way of proxying requests, but that may end up incurring more costs than desired.

pamelafox avatar Jan 18 '24 00:01 pamelafox

I suggest:

* Store each frontend's data in a different index (you could also use search fields with filters, but if the data is different enough, I think a separate index makes sense).

* Adding a mapping in the backend from frontend domain to search index, to make sure you send back data from the right index. You'll need to propagate that index to the approach files instead of configuring it globally, as it's done now.

* Deploy frontends using Static Web Apps. https://github.com/Azure-Samples/azure-search-openai-javascript is already designed for deployment on SWA so you may want to use that, as it will be cheaper than running each frontend on App Service. You can also deploy this frontend to SWA or to separate App Service instances if preferred.

As for monitoring, this backend is already instrumented with OpenTelemetry, so you should see stats show up in Azure Monitor. You can filter the "requests" table per "url" column. For more advanced monitoring, consult the Application Insights docs.

You could also look into APIM as a way of proxying requests, but that may end up incurring more costs than desired.

Thank you, if possible can you elaborate a bit more on the second point about adding a mapping, also how do i deploy only the backend, will it work with SWA or do i stick with App Service for running the backend?

Again Thank you, this helps alot!

thwayant avatar Jan 18 '24 05:01 thwayant

By a mapping, I meant a Python dictionary, like {"frontend-domain": "index"}, and you could extract the referrer from the request. Referrers can be faked, so you'd likely want additional forms of verification/authentication if they're accessing private data.

As for deploying only the backend from this repo, you could delete the prepackage route from azure.yaml and the / and /asserts routes in app.py. That would affectively give you an App Service backend with no Node frontend.

pamelafox avatar Jan 22 '24 18:01 pamelafox

Thank You,this is very helpful.

On Tue, Jan 23, 2024 at 12:25 AM Pamela Fox @.***> wrote:

By a mapping, I meant a Python dictionary, like {"frontend-domain": "index"}, and you could extract the referrer from the request. Referrers can be faked, so you'd likely want additional forms of verification/authentication if they're accessing private data.

As for deploying only the backend from this repo, you could delete the prepackage route from azure.yaml and the / and /asserts routes in app.py. That would affectively give you an App Service backend with no Node frontend.

— Reply to this email directly, view it on GitHub https://github.com/Azure-Samples/azure-search-openai-demo/issues/1146#issuecomment-1904611371, or unsubscribe https://github.com/notifications/unsubscribe-auth/A22UKSXMU6TNAPTSXJH5LYTYP2Y2FAVCNFSM6AAAAABB6KB7TOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBUGYYTCMZXGE . You are receiving this because you authored the thread.Message ID: @.***>

thwayant avatar Jan 23 '24 05:01 thwayant