Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.95k stars 4.09k forks source link

Deploy only frontend or backend #266

Open ArunEPRO opened 1 year ago

ArunEPRO commented 1 year ago

Please provide us with the following information:

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

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

Minimal steps to reproduce

How to deploy only backend files or frontend files. I added 150MB of enterprise data and deployed the entire environment. Now I need to update single file in frontend or backend. If I give azd up - entire environment (frontend, backend, data files, etc are getting deployed)

Any log messages given by the failure

no

Expected/desired behavior

Only selected backend or front end must be deployed based on need.

OS and Version?

Linux - App Service

azd version?

azd version 1.0.1 (commit e0cd1aca716fa5d08704beade7dcc734fe68f5f1)

den130 commented 1 year ago

If you just want to update indexes, you can run the script:

.\scripts\prepdocs.ps1

ArunEPRO commented 1 year ago

I understand you mean data folder as indexes. Yes ".\scripts\prepdocs.ps1" can be used for updating the data.

I need to make a change to the UI or prompt. azd up is not a very good solution as it incurs me additional cost by reuploading all data.

Is there an option for that ?

dvag-christian-ley commented 1 year ago

You can comment out the hook in the azure.yaml to stop azd up from reuploading on every frontend/backend change that you want to deploy.

name: azure-search-openai-demo
metadata:
  template: azure-search-openai-demo@0.0.2-beta
services:
  backend:
    project: ./app/backend
    language: py
    host: appservice
    hooks:
      prepackage:
        windows:
          shell: pwsh
          run: cd ../frontend;npm install;npm run build
          interactive: true
          continueOnError: false
        posix:
          shell: sh
          run: cd ../frontend;npm install;npm run build
          interactive: true
          continueOnError: false
# hooks:
#     postprovision:
#       windows:
#         shell: pwsh
#         run: ./scripts/prepdocs.ps1
#         interactive: true
#         continueOnError: false
#       posix:
#         shell: sh
#         run: ./scripts/prepdocs.sh
#         interactive: true
#         continueOnError: false
pamelafox commented 1 year ago

Another option, if you haven't changed any of the infra/ Bicep files, is to just run azd deploy. That will first run the prepackage hook, but it wont run the postprovision hook.

Here's what it looks like for me:

vscode ➜ /workspaces/azure-search-openai-demo (main) $ azd deploy

Deploying services (azd deploy)

  |       | Deploying service backendExecuting prepackage hook => /tmp/azd-prepackage-2644389450.sh
  |===    | Deploying service backend(##################) ⠇ reify:@esbuild/android-arm: timing reifyNode:node_modul
  |====   | Deploying service backend(##################) ⠇ reify:@esbuild/android-arm: timing reifyNode:node_modul

up to date, audited 124 packages in 586ms

10 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
  |=====  | Deploying service backend
> frontend@0.0.0 build
> tsc && vite build

  |=======| Deploying service backendvite v4.1.1 building for production...
✓ 1250 modules transformed.
../backend/static/index.html                    0.47 kB
../backend/static/assets/github-fab00c2d.svg    0.96 kB
../backend/static/assets/index-2fb53ec2.css     7.44 kB │ gzip:   2.19 kB
../backend/static/assets/index-7abdfda7.js    625.74 kB │ gzip: 204.87 kB │ map: 5,054.95 kB

(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
  (✓) Done: Deploying service backend
  - Endpoint: https://app-backend-randomid.azurewebsites.net/

SUCCESS: Your Azure app has been deployed!
You can view the resources created under the resource group rg-openai-search in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/32ea8a26-5b40-4838-b6cb-be5c89a57c16/resourceGroups/rg-openai-search/overview
ArunEPRO commented 1 year ago

@pamelafox - thanks and it sounds to be promising. More details about azd deploy were not found in the GitHub as well as cli.

Will a new URL be created for accessing the front end or will it overwrite the existing files in AppService?

pamelafox commented 1 year ago

You can learn more about azd and its various commands here: https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview

It will be the same URL, it just re-deploys the files and restarts the App Service.

douglaswross commented 1 year ago

@pamelafox azd deploy is great for deploying backend code, however does not seem to deploy the UI code - e.g. under the frontend folder.

e.g. When I run AZD deploy if I have made changes to the pages>layout>layout.tsx file, I cannot see that change on the cloud based deployment.

I can see the change locally by using start.sh

Am I not understanding, or is there a way to also deploy the "frontend" changes as well as the "backend" changes with azd deploy?

pamelafox commented 1 year ago

It should deploy both, due to the prepackage scripts in azure.yaml:

services:
  backend:
    project: ./app/backend
    language: py
    host: appservice
    hooks:
      prepackage:
        windows:
          shell: pwsh
          run:  cd ../frontend;npm install;npm run build
          interactive: true
          continueOnError: false
        posix:
          shell: sh
          run:  cd ../frontend;npm install;npm run build
          interactive: true
          continueOnError: false

npm run build will generate the static folder which is then used by the backend. Do you not see the packaging step running when you deploy?

douglaswross commented 1 year ago

@pamelafox - yes sorry - silly on my behalf - realised my mistake thanks for helping me.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.

aropenai commented 3 months ago

Anyone tried to deploy only front end ? Does it work? Please share inputs and procedure