Skip to content

Commit 5c517ef

Browse files
Merge pull request #428 from microsoft/dev
fix: merge dev to main- improving development environment setup, deployment configurations, and documentation
2 parents 6437951 + 44d64da commit 5c517ef

23 files changed

+3135
-1363
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
44
"forwardPorts": [50505],
55
"features": {
6-
"ghcr.io/azure/azure-dev/azd:latest": {}
6+
"ghcr.io/devcontainers/features/node:1": {
7+
"nodeGypDependencies": true,
8+
"installYarnUsingApt": true,
9+
"version": "lts",
10+
"pnpmVersion": "latest",
11+
"nvmVersion": "latest"
12+
},
13+
"ghcr.io/devcontainers/features/azure-cli:1": {
14+
"installBicep": true,
15+
"version": "latest",
16+
"bicepVersion": "latest"
17+
},
18+
"ghcr.io/azure/azure-dev/azd:0": {
19+
"version": "stable"
20+
}
721
},
822
"customizations": {
923
"vscode": {
@@ -16,7 +30,7 @@
1630
]
1731
}
1832
},
19-
"postStartCommand": "git pull origin main && python3 -m pip install -r infra/scripts/index_scripts/requirements.txt && curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash && chmod +x ./scripts/quota_check_params.sh",
33+
"postCreateCommand": "bash ./.devcontainer/setup_env.sh",
2034
"remoteUser": "vscode",
2135
"hostRequirements": {
2236
"memory": "4gb"

.devcontainer/setup_env.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
git fetch
4+
git pull
5+
6+
# provide execute permission to quotacheck script
7+
sudo chmod +x ./scripts/quota_check_params.sh

.github/workflows/deploy.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
schedule:
88
- cron: '0 9,21 * * *' # Runs at 9:00 AM and 9:00 PM GMT
99

10+
env:
11+
GPT_MIN_CAPACITY: 10
12+
TEXT_EMBEDDING_MIN_CAPACITY: 10
13+
1014
jobs:
1115
deploy:
1216
runs-on: ubuntu-latest
@@ -30,8 +34,8 @@ jobs:
3034
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
3135
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
3236
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
33-
export GPT_MIN_CAPACITY="30"
34-
export TEXT_EMBEDDING_MIN_CAPACITY="30"
37+
export GPT_MIN_CAPACITY=${{ env.GPT_MIN_CAPACITY }}
38+
export TEXT_EMBEDDING_MIN_CAPACITY=${{ env.TEXT_EMBEDDING_MIN_CAPACITY }}
3539
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"
3640
3741
chmod +x scripts/checkquota.sh
@@ -114,17 +118,17 @@ jobs:
114118
--template-file infra/main.json \
115119
--parameters \
116120
environmentName="${{ env.SOLUTION_PREFIX }}" \
117-
secondaryLocation="eastus2" \
121+
secondaryLocation="northcentralus" \
118122
deploymentType="GlobalStandard" \
119123
gptModelName="gpt-4o" \
120124
azureOpenaiAPIVersion="2024-05-01-preview" \
121-
gptDeploymentCapacity="10" \
125+
gptDeploymentCapacity=${{ env.GPT_MIN_CAPACITY }} \
122126
embeddingModel="text-embedding-ada-002" \
123-
embeddingDeploymentCapacity="30" \
127+
embeddingDeploymentCapacity=${{ env.TEXT_EMBEDDING_MIN_CAPACITY }} \
124128
imageTag="latest"
125129
126130
- name: Extract AI Services and Key Vault Names
127-
if: always()
131+
if: always() && steps.check_create_rg.outcome == 'success'
128132
run: |
129133
echo "Fetching AI Services and Key Vault names before deletion..."
130134
@@ -145,7 +149,7 @@ jobs:
145149
echo "AI_SERVICES=$AI_SERVICES" >> $GITHUB_ENV
146150

147151
- name: Delete Bicep Deployment
148-
if: success()
152+
if: always()
149153
run: |
150154
set -e
151155
echo "Checking if resource group exists..."
@@ -162,6 +166,7 @@ jobs:
162166
fi
163167
164168
- name: Wait for Resource Deletion to Complete
169+
if: always()
165170
run: |
166171
echo "Waiting for all deployed resources (including AI Services) to be deleted..."
167172
@@ -289,7 +294,7 @@ jobs:
289294
290295
EMAIL_BODY=$(cat <<EOF
291296
{
292-
"body": "<p>Dear Team,</p><p>We would like to inform you that the Research Assistant Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
297+
"body": "<p>Dear Team,</p><p>We would like to inform you that the DocGen Automation process has encountered an issue and has failed to complete successfully.</p><p><strong>Build URL:</strong> ${RUN_URL}<br> ${OUTPUT}</p><p>Please investigate the matter at your earliest convenience.</p><p>Best regards,<br>Your Automation Team</p>"
293298
}
294299
EOF
295300
)

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ myenv
1111

1212
scriptsenv/
1313

14-
scriptenv
14+
scriptenv
15+
pdf

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "python",
77
"request": "launch",
88
"module": "quart",
9-
"cwd": "${workspaceFolder}",
9+
"cwd": "${workspaceFolder}/src",
1010
"env": {
1111
"QUART_APP": "app:app",
1212
"QUART_ENV": "development",

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The sample data is sourced from generic AI-generated promissory notes.The docume
4141

4242
### Key features
4343
<details open>
44-
  <summary>Click to learn more about the key features this solution enables</summary>
44+
<summary>Click to learn more about the key features this solution enables</summary>
4545

4646
- **Semantic search** <br/>
4747
Azure AI Search to enable RAG and grounding of the application on the processed dataset.​
@@ -62,7 +62,7 @@ Quick deploy
6262
</h2>
6363

6464
### How to install or deploy
65-
Follow the quick deploy steps on the deployment guide to deploy this solution to your own Azure subscription.
65+
Follow the quick deploy steps on the deployment guide to deploy this solution to your own Azure subscription.
6666

6767
[Click here to launch the deployment guide](./docs/DeploymentGuide.md)
6868
<br/><br/>
@@ -130,7 +130,7 @@ Put your data to work by reducing blank page anxiety, speeding up document draft
130130

131131
### Business value
132132
<details>
133-
  <summary>Click to learn more about what value this solution provides</summary>
133+
<summary>Click to learn more about what value this solution provides</summary>
134134

135135
- **Draft templates quickly** <br/>
136136
Put your data to work to create any kind of document that is supported by a large data library.
@@ -217,4 +217,4 @@ You acknowledge that the Software and Microsoft Products and Services (1) are no
217217

218218
You acknowledge the Software is not subject to SOC 1 and SOC 2 compliance audits. No Microsoft technology, nor any of its component technologies, including the Software, is intended or made available as a substitute for the professional advice, opinion, or judgement of a certified financial services professional. Do not use the Software to replace, substitute, or provide professional financial advice or judgment.
219219

220-
BY ACCESSING OR USING THE SOFTWARE, YOU ACKNOWLEDGE THAT THE SOFTWARE IS NOT DESIGNED OR INTENDED TO SUPPORT ANY USE IN WHICH A SERVICE INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE COULD RESULT IN THE DEATH OR SERIOUS BODILY INJURY OF ANY PERSON OR IN PHYSICAL OR ENVIRONMENTAL DAMAGE (COLLECTIVELY, “HIGH-RISK USE”), AND THAT YOU WILL ENSURE THAT, IN THE EVENT OF ANY INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE, THE SAFETY OF PEOPLE, PROPERTY, AND THE ENVIRONMENT ARE NOT REDUCED BELOW A LEVEL THAT IS REASONABLY, APPROPRIATE, AND LEGAL, WHETHER IN GENERAL OR IN A SPECIFIC INDUSTRY. BY ACCESSING THE SOFTWARE, YOU FURTHER ACKNOWLEDGE THAT YOUR HIGH-RISK USE OF THE SOFTWARE IS AT YOUR OWN RISK.
220+
BY ACCESSING OR USING THE SOFTWARE, YOU ACKNOWLEDGE THAT THE SOFTWARE IS NOT DESIGNED OR INTENDED TO SUPPORT ANY USE IN WHICH A SERVICE INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE COULD RESULT IN THE DEATH OR SERIOUS BODILY INJURY OF ANY PERSON OR IN PHYSICAL OR ENVIRONMENTAL DAMAGE (COLLECTIVELY, “HIGH-RISK USE”), AND THAT YOU WILL ENSURE THAT, IN THE EVENT OF ANY INTERRUPTION, DEFECT, ERROR, OR OTHER FAILURE OF THE SOFTWARE, THE SAFETY OF PEOPLE, PROPERTY, AND THE ENVIRONMENT ARE NOT REDUCED BELOW A LEVEL THAT IS REASONABLY, APPROPRIATE, AND LEGAL, WHETHER IN GENERAL OR IN A SPECIFIC INDUSTRY. BY ACCESSING THE SOFTWARE, YOU FURTHER ACKNOWLEDGE THAT YOUR HIGH-RISK USE OF THE SOFTWARE IS AT YOUR OWN RISK.

azure.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ hooks:
3232
Write-Host "Web app URL: "
3333
Write-Host "$env:WEB_APP_URL" -ForegroundColor Cyan
3434
Write-Host "`nIf you want to use the Sample Data, run the following command in the Bash terminal to process it:"
35-
Write-Host "bash ./infra/scripts/process_sample_data.sh $env:STORAGE_ACCOUNT_NAME $env:STORAGE_CONTAINER_NAME $env:KEY_VAULT_NAME $env:COSMOSDB_ACCOUNT_NAME $env:RESOURCE_GROUP_NAME" -ForegroundColor Cyan
35+
Write-Host "bash ./infra/scripts/process_sample_data.sh" -ForegroundColor Cyan
3636
shell: pwsh
3737
continueOnError: false
3838
interactive: true
@@ -41,8 +41,8 @@ hooks:
4141
echo "Web app URL: "
4242
echo $WEB_APP_URL
4343
echo ""
44-
echo "If you want to use the Sample Data, run the following command in the terminal to process it:"
45-
echo "bash ./infra/scripts/process_sample_data.sh $STORAGE_ACCOUNT_NAME $STORAGE_CONTAINER_NAME $KEY_VAULT_NAME $COSMOSDB_ACCOUNT_NAME $RESOURCE_GROUP_NAME"
44+
echo "If you want to use the Sample Data, run the following command in the bash terminal to process it:"
45+
echo "bash ./infra/scripts/process_sample_data.sh"
4646
shell: sh
4747
continueOnError: false
4848
interactive: true

docs/DeploymentGuide.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,16 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
148148
azd up
149149
```
150150
151-
3. Provide an `azd` environment name (e.g., "cpsapp").
151+
3. Provide an `azd` environment name (e.g., "dgapp").
152152
4. Select a subscription from your Azure account and choose a location that has quota for all the resources.
153153
- This deployment will take *7-10 minutes* to provision the resources in your account and set up the solution with sample data.
154154
- If you encounter an error or timeout during deployment, changing the location may help, as there could be availability constraints for the resources.
155155
156156
5. Once the deployment has completed successfully and you would like to use the sample data, run the bash command printed in the terminal. The bash command will look like the following:
157+
```shell
158+
bash ./infra/scripts/process_sample_data.sh
159+
```
160+
If you don't have azd env then you need to pass parameters along with the command. Then the command will look like the following:
157161
```shell
158162
bash ./infra/scripts/process_sample_data.sh <Storage-Account-name> <Storgae-Account-container-name> <Key-Vault-name> <CosmosDB-Account-name> <Resource-Group-name>
159163
```

docs/README_LOCAL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Deploy from your local machine
22

33
#### Local Setup: Basic Chat Experience
4-
1. Copy `.env.sample` to a new file called `.env` and configure the settings as described in the [Environment variables](#environment-variables) section.
4+
1. Copy `.env.sample` present in `src` folder to a new file called `.env` and configure the settings as described in the [Environment variables](#environment-variables) section.
55

66
These variables are required:
77
- `AZURE_OPENAI_RESOURCE`
@@ -17,7 +17,7 @@
1717

1818
See the [documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#example-response-2) for more information on these parameters.
1919

20-
2. Start the app with `start.cmd`. This will build the frontend, install backend dependencies, and then start the app. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`.
20+
2. Start the app with `start.cmd` or `start.sh`. This will build the frontend, install backend dependencies, and then start the app. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`.
2121

2222
3. You can see the local running app at http://127.0.0.1:50505. If you experience a port conflict and the app does not load, stop the application in the terminal (CTRL-C on Windows), edit the `start.cmd` file and change the port to a value not in use (i.e., 5000).
2323

@@ -50,7 +50,7 @@ NOTE: You may find you need to set: MacOS: `export NODE_OPTIONS="--max-old-space
5050
- `AZURE_SEARCH_STRICTNESS`
5151
- `AZURE_OPENAI_EMBEDDING_NAME`
5252

53-
3. Start the app with `start.cmd`. This will build the frontend, install backend dependencies, and then start the app. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`.
53+
3. Start the app with `start.cmd` or `start.sh`. This will build the frontend, install backend dependencies, and then start the app. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`.
5454
4. You can see the local running app at http://127.0.0.1:50505. If you experience a port conflict and the app does not load, stop the application in the terminal (CTRL-C on Windows), edit the `start.cmd` file and change the port to a value not in use (i.e., 5000).
5555

5656
NOTE: You may find you need to set: MacOS: `export NODE_OPTIONS="--max-old-space-size=8192"` or Windows: `set NODE_OPTIONS=--max-old-space-size=8192` to avoid running out of memory when building the frontend.
@@ -62,7 +62,7 @@ To enable chat history, you will need to set up CosmosDB resources. The ARM temp
6262
- `AZURE_COSMOSDB_CONVERSATIONS_CONTAINER`
6363
- `AZURE_COSMOSDB_ACCOUNT_KEY`
6464

65-
As above, start the app with `start.cmd`, then visit the local running app at http://127.0.0.1:50505. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`. If you experience a port conflict and the app does not load, stop the application in the terminal (CTRL-C on Windows), edit the `start.cmd` file and change the port to a value not in use (i.e., 5000).
65+
As above, start the app with `start.cmd` or `start.sh`, then visit the local running app at http://127.0.0.1:50505. Or, just run the backend in debug mode using the VSCode debug configuration in `.vscode/launch.json`. If you experience a port conflict and the app does not load, stop the application in the terminal (CTRL-C on Windows), edit the `start.cmd` file and change the port to a value not in use (i.e., 5000).
6666

6767
#### Local Setup: Enable Message Feedback
6868
To enable message feedback, you will need to set up CosmosDB resources. Then specify these additional environment variable:
@@ -75,10 +75,10 @@ To enable message feedback, you will need to set up CosmosDB resources. Then spe
7575

7676
You can use the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) to deploy the app from your local machine. Make sure you have version 2.48.1 or later.
7777

78-
If this is your first time deploying the app, you can use [az webapp up](https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-up). Run the following two commands from the root folder of the repo, updating the placeholder values to your desired app name, resource group, location, and subscription. You can also change the SKU if desired.
78+
If this is your first time deploying the app, you can use [az webapp up](https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-up). Run the following two commands from the `src` folder of the repo, updating the placeholder values to your desired app name, resource group, location, and subscription. You can also change the SKU if desired.
7979

8080
1. `az webapp up --runtime PYTHON:3.11 --sku B1 --name <new-app-name> --resource-group <resource-group-name> --location <azure-region> --subscription <subscription-name>`
81-
1. `az webapp config set --startup-file "python3 -m gunicorn app:app" --name <new-app-name>`
81+
1. `az webapp config set --startup-file "python3 -m gunicorn app:app" --name <new-app-name> --resource-group <resource-group-name>`
8282

8383
If you've deployed the app previously, first run this command to update the appsettings to allow local code deployment:
8484

@@ -88,10 +88,10 @@ Check the runtime stack for your app by viewing the app service resource in the
8888

8989
Check the SKU in the same way. Use the abbreviated SKU name in the argument below, e.g. for "Basic (B1)" the SKU is `B1`.
9090

91-
Then, use these commands to deploy your local code to the existing app:
91+
Then, use these commands from `src` folder to deploy your local code to the existing app:
9292

9393
1. `az webapp up --runtime <runtime-stack> --sku <sku> --name <existing-app-name> --resource-group <resource-group-name>`
94-
1. `az webapp config set --startup-file "python3 -m gunicorn app:app" --name <existing-app-name>`
94+
1. `az webapp config set --startup-file "python3 -m gunicorn app:app" --name <existing-app-name> --resource-group <resource-group-name>`
9595

9696
Make sure that the app name and resource group match exactly for the app that was previously deployed.
9797

infra/deploy_ai_foundry.bicep

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ param solutionLocation string
44
param keyVaultName string
55
param deploymentType string
66
param gptModelName string
7-
param gptModelVersion string
7+
param azureOpenaiAPIVersion string
88
param gptDeploymentCapacity int
99
param embeddingModel string
1010
param embeddingDeploymentCapacity int
@@ -141,6 +141,7 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
141141
}
142142
kind: 'AIServices'
143143
properties: {
144+
publicNetworkAccess: 'Enabled'
144145
customSubDomainName: aiServicesName
145146
apiProperties: {
146147
//statisticsEnabled: false
@@ -363,7 +364,7 @@ resource azureOpenAIApiVersionEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-0
363364
parent: keyVault
364365
name: 'AZURE-OPENAI-PREVIEW-API-VERSION'
365366
properties: {
366-
value: gptModelVersion //'2024-02-15-preview'
367+
value: azureOpenaiAPIVersion //'2024-02-15-preview'
367368
}
368369
}
369370

0 commit comments

Comments
 (0)