Skip to content

Commit

Permalink
Fully azdevify the application (#281)
Browse files Browse the repository at this point in the history
* azdevify this sample and add azd new feature in devcontainer

* instead parameters.json file with .bicepparam

* processing format

* keep consistent casing for params

* move appsettings

* remove some invalid changes

* fix format issues

* Remove depandsOn

* remove resources file

* remov keys from output

* remove existing reference in module

* update ReadMe

* add rgName in listkeys

* add use keyvault option

add keyvault option to get secret keys

remove invalid changes

add param useKeyVault

* set default value in .bicepparam

* fix some bugs

* update rbac

* update rbac

* fix some format and update infra core

* Update openai to v1

* use resourcegroup.name() instead pass in rhName

* Revert "Update openai to v1"

* add token provider

* Update requirements.txt

* revert

* fix chat

* Update TextProcessingTool.py

* update KeyVault options

* abstract auth type with define method

* remove invalid infra/core

* update readme and storage.bicep in infra/core

* Update output format

* default to use rbac

* add some comments

* add readme and speech service related code in main.bicep

* fix azd deploy problem

* move code folder structure

* fix ci error and some format issue

* fix some format issue

* fix some format issues

* little changes

* fix backend issue

* Fixed mismatched requirements

* Fix build-frontend

* fix function error

* Run black against the code base

* try to fix ci error

* fix ci errors

* fix azd deploy web error

* fix web debug error and update main.bicep

* resolve conflict

* fix tests path

* try to fix CI/build error

* Merge main

* Fixed Requirements

* Black fixes

---------

Co-authored-by: zedy <zedy@wicresoft.com>
Co-authored-by: ChenxiJiang333 <v-chenjiang@microsoft.com>
Co-authored-by: Wenjie Yu(MSFT) <81678720+zedy-wj@users.noreply.github.com>
Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com>
Co-authored-by: ross-p-smith <rosmith@microsoft.com>
Co-authored-by: Ross Smith <ross-p-smith@users.noreply.github.com>
  • Loading branch information
7 people authored Feb 21, 2024
1 parent 9a1b43b commit 2623e1b
Show file tree
Hide file tree
Showing 149 changed files with 3,654 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"TeamsDevApp.ms-teams-vscode-extension"
],
"settings": {
"azureFunctions.projectSubpath": "code/batch",
"azureFunctions.projectSubpath": "code/backend/batch",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.pythonPath": "/usr/local/bin/python"
}
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pip install --upgrade pip

pip install -r code/requirements.txt -r code/app/requirements.txt -r extensions/backend/requirements.txt
pip install -r code/requirements.txt -r code/backend/requirements.txt -r code/backend/batch/requirements.txt

pip install -r code/dev-requirements.txt

Expand Down
7 changes: 6 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ ORCHESTRATION_STRATEGY=openai_functions
#Speech-to-text feature
AZURE_SPEECH_SERVICE_KEY=
AZURE_SPEECH_SERVICE_REGION=
AZURE_AUTH_TYPE=rbac
# Auth type environment variables.
# When AZURE_AUTH_TYPE=rbac, please make sure variable USE_KEY_VAULT=false
# When USE_KEY_VAULT=true, please make sure to set AZURE_KEY_VAULT_ENDPOINT
AZURE_AUTH_TYPE=keys
USE_KEY_VAULT=true
AZURE_KEY_VAULT_ENDPOINT=
4 changes: 2 additions & 2 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
architecture: x64
- name: Install dependencies
run: |
pip install -r code/requirements.txt -r code/dev-requirements.txt -r code/app/requirements.txt
pip install -r code/requirements.txt -r code/dev-requirements.txt -r code/backend/requirements.txt
- name: Run Python tests
run: python -m pytest --rootdir=code -m "not azure"
run: cd code/; python -m pytest -m "not azure"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# generated frontend files
code/app/static/
code/static/

# User-specific files
*.rsuser
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.2.0
hooks:
- id: black
language_version: python3
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"run",
"Admin.py"
],
"cwd": "${workspaceFolder}/code/admin",
"cwd": "${workspaceFolder}/code/backend",
"preLaunchTask": "pip install (code)",
},
{
Expand All @@ -31,14 +31,14 @@
"--debug",
"run"
],
"cwd": "${workspaceFolder}/code/app",
"cwd": "${workspaceFolder}/code",
"preLaunchTask": "pip install (code)"
},
{
"name": "Launch Frontend (UI)",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/code/app/frontend",
"cwd": "${workspaceFolder}/code/frontend",
"preLaunchTask": "npm install (code)",
"runtimeExecutable": "npm",
"runtimeArgs": [
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"azureFunctions.deploySubpath": "code\\batch",
"azureFunctions.deploySubpath": "code\\backend\\batch",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"isBackground": true,
"dependsOn": "pip install (functions)",
"options": {
"cwd": "${workspaceFolder}/backend"
"cwd": "${workspaceFolder}/code/backend/batch"
}
},
{
Expand All @@ -26,7 +26,7 @@
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/backend"
"cwd": "${workspaceFolder}/code/backend"
}
},
{
Expand All @@ -44,7 +44,7 @@
"command": "npm install",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/code/app/frontend"
"cwd": "${workspaceFolder}/code/frontend"
}
}
]
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ endif
help: ## 💬 This help message :)
@grep -E '[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}'

ci: unittest build-frontend ## 🚀 Continuous Integration (called by Github Actions)
ci: lint unittest build-frontend ## 🚀 Continuous Integration (called by Github Actions)

lint: ## 🧹 Lint the code
@echo -e "\e[34m$@\e[0m" || true
@flake8 code

unittest: ## 🧪 Run the unit tests
@echo -e "\e[34m$@\e[0m" || true
@python -m pytest -m "not azure"
@cd code/ && python -m pytest -m "not azure"

build-frontend: ## 🏗️ Build the Frontend webapp
@echo -e "\e[34m$@\e[0m" || true
@cd code/app/frontend && npm install && npm run build
@cd code/frontend && npm install && npm run build

azd-login: ## 🔑 Login to Azure with azd and a SPN
@echo -e "\e[34m$@\e[0m" || true
@azd auth login --client-id ${AZURE_CLIENT_ID} --client-secret ${AZURE_CLIENT_SECRET} --tenant-id ${AZURE_TENANT_ID}
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,46 @@ az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file


![A screenshot of the chat app.](./media/web-unstructureddata.png)
### Running the sample using the Azure Developer CLI (azd)

The Azure Developer CLI (`azd`) is a developer-centric command-line interface (CLI) tool for creating Azure applications.

You need to install it before running and deploying with the Azure Developer CLI. (If you use the devcontainer, everything is already installed)

### Windows

```powershell
powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"
```

### Linux/MacOS

```
curl -fsSL https://aka.ms/install-azd.sh | bash
```

After logging in with the following command, you will be able to use the `azd` cli to quickly provision and deploy the application.

```
azd auth login
```

Then, execute the `azd init` command to initialize the environment (You do not need to run this command if you already have the code or have opened this in a Codespace or DevContainer).
```
azd init -t chat-with-your-data-solution-accelerator
```
Enter an environment name.

**Notes:** the default auth type uses keys, if you want to switch to rbac, please run `azd env set AUTH_TYPE rbac`.

Then, run `azd up` to provision all the resources to Azure and deploy the code to those resources.
```
azd up
```

Select your desired `subscription` and `location`. Wait a moment for the resource deployment to complete, click the website endpoint and you will see the web app page.

You can also run the sample directly locally (See below).

### [Local deployment instructions](./docs/LOCAL_DEPLOYMENT.md)
To customize the accelerator or run it locally, first, copy the .env.sample file to your development environment's .env file, and edit it according to environment variable values table. Learn more about deploying locally [here](./docs/LOCAL_DEPLOYMENT.md).
Expand Down
33 changes: 33 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: chat-with-your-data-solution-accelerator
metadata:
template: chat-with-your-data-solution-accelerator@0.0.1-beta

services:
web:
project: ./code
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

adminweb:
project: ./code/backend
language: py
host: appservice

function:
project: ./code/backend/batch
language: py
host: function
Loading

0 comments on commit 2623e1b

Please sign in to comment.