Skip to content

Commit cc74001

Browse files
Roopan-MicrosoftPriyanka-MicrosoftPrajwal-MicrosoftRafi-MicrosoftNirajC-Microsoft
authored
fix: merging dev changes to main branch (#649)
* model deployment when reusing existing foundry * change model deployment name * removed system managed identity code * seggregated the files * fix: Updated file names * chore: down merging main into dev (#638) * fixed opent telemetry issue CustomDomainInUse, FlagMustBeSetForRestore (#618) (#619) Co-authored-by: VishalS-Microsoft <v-vishshinde@microsoft.com> * directory update in dependabot template (#634) --------- Co-authored-by: NirajC-Microsoft <v-nirajcha@microsoft.com> Co-authored-by: VishalS-Microsoft <v-vishshinde@microsoft.com> Co-authored-by: Prajwal-Microsoft <v-dcprajwal@microsoft.com> * added for cross-subscription existing AI project resource ID * update * fix: agent cleanup (#639) * Agent deletion handled successfully * use get azure credentials * remove unused import --------- Co-authored-by: Shreyas-Microsoft <v-swaikar@microsft.com> * TS( 21657) Bicep Standard code changes * Added required env variables for local debugging in .env generated by azd up * Added "Required/Optional" and changed aiProjectName suffix. * removed location tag * foundry project documentation * corrected name * updated CAdeploy.yml * update CAdeploy.yml * changed pipeline variable * updated main.json file * updated yml file * test * test * update * update * test * update CAdeploy.yml * CustomizingAzdparamMd * deploymentMdUpdate * Updated * Update infra/main.bicep Fixed typo error. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/App/backend/plugins/chat_with_data_plugin.py Updated the finally block for function "get_SQL_Response" Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update infra/main.bicep Removed Commented-out code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert Copilot suggestion: `and project_client` is unnecessary. `project_client` is always initialized before thread creation, so `if thread:` is sufficient. --------- Co-authored-by: Priyanka-Microsoft <v-prisinghal@microsoft.com> Co-authored-by: Prajwal D C <v-dcprajwal@microsoft.com> Co-authored-by: Rafi-Microsoft <v-rafmd@microsoft.com> Co-authored-by: NirajC-Microsoft <v-nirajcha@microsoft.com> Co-authored-by: VishalS-Microsoft <v-vishshinde@microsoft.com> Co-authored-by: Kanchan Nagshetti (Persistent Systems Inc) <v-knagshetti@microsoft.com> Co-authored-by: Shreyas-Microsoft <v-swaikar@microsoft.com> Co-authored-by: Shreyas-Microsoft <v-swaikar@microsft.com> Co-authored-by: Bangarraju-Microsoft <v-golib@microsoft.com> Co-authored-by: Prasanjeet-Microsoft <v-singhprasa@microsoft.com> Co-authored-by: UtkarshMishra-Microsoft <v-utkamishra@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3d47f21 commit cc74001

28 files changed

+2167
-1132
lines changed

.github/workflows/CAdeploy.yml

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- dev
88
- demo
99
schedule:
10-
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
10+
- cron: "0 6,18 * * *" # Runs at 6:00 AM and 6:00 PM GMT
1111

1212
env:
1313
GPT_MIN_CAPACITY: 200
@@ -29,7 +29,6 @@ jobs:
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@v4
32-
3332
- name: Install ODBC Driver 18 for SQL Server
3433
run: |
3534
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
@@ -81,7 +80,6 @@ jobs:
8180

8281
- name: Install Bicep CLI
8382
run: az bicep install
84-
8583
- name: Set Deployment Region
8684
id: set_region
8785
run: |
@@ -98,7 +96,6 @@ jobs:
9896
UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
9997
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
10098
echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"
101-
10299
- name: Check and Create Resource Group
103100
id: check_create_rg
104101
run: |
@@ -114,7 +111,6 @@ jobs:
114111
fi
115112
# Set output for other jobs
116113
echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
117-
118114
- name: Generate Unique Solution Prefix
119115
id: generate_solution_prefix
120116
run: |
@@ -137,7 +133,6 @@ jobs:
137133
else TAG="latest"; fi
138134
echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV
139135
echo "Image Tag: $TAG"
140-
141136
- name: Deploy and extract values from deployment output
142137
id: get_output
143138
run: |
@@ -149,19 +144,17 @@ jobs:
149144
DEPLOY_OUTPUT=$(az deployment group create \
150145
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
151146
--template-file infra/main.bicep \
152-
--parameters aiDeploymentsLocation=${{ env.AZURE_LOCATION }} environmentName=${{ env.SOLUTION_PREFIX }} cosmosLocation=westus gptDeploymentCapacity=${{ env.GPT_MIN_CAPACITY }} embeddingDeploymentCapacity=${{ env.TEXT_EMBEDDING_MIN_CAPACITY }} imageTag=${{ env.IMAGE_TAG }} \
147+
--parameters aiDeploymentsLocation=${{ env.AZURE_LOCATION }} solutionName=${{ env.SOLUTION_PREFIX }} cosmosLocation=westus gptDeploymentCapacity=${{ env.GPT_MIN_CAPACITY }} embeddingDeploymentCapacity=${{ env.TEXT_EMBEDDING_MIN_CAPACITY }} imageTag=${{ env.IMAGE_TAG }} \
153148
--query "properties.outputs" -o json)
154149
155-
156-
157150
echo "Deployment output: $DEPLOY_OUTPUT"
158151
if [[ -z "$DEPLOY_OUTPUT" ]]; then
159152
echo "Error: Deployment output is empty. Please check the deployment logs."
160153
exit 1
161154
fi
162155
163-
export AI_FOUNDARY_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.aI_FOUNDRY_NAME.value')
164-
echo "AI_FOUNDARY_NAME=$AI_FOUNDARY_NAME" >> $GITHUB_ENV
156+
export AI_FOUNDRY_RESOURCE_ID=$(echo "$DEPLOY_OUTPUT" | jq -r '.aI_FOUNDRY_RESOURCE_ID.value')
157+
echo "AI_FOUNDRY_RESOURCE_ID=$AI_FOUNDRY_RESOURCE_ID" >> $GITHUB_ENV
165158
export SEARCH_SERVICE_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.aI_SEARCH_SERVICE_NAME.value')
166159
echo "SEARCH_SERVICE_NAME=$SEARCH_SERVICE_NAME" >> $GITHUB_ENV
167160
export COSMOS_DB_ACCOUNT_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.cosmosdB_ACCOUNT_NAME.value')
@@ -172,8 +165,8 @@ jobs:
172165
echo "STORAGE_CONTAINER=$STORAGE_CONTAINER" >> $GITHUB_ENV
173166
export KEYVAULT_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.keY_VAULT_NAME.value')
174167
echo "KEYVAULT_NAME=$KEYVAULT_NAME" >> $GITHUB_ENV
175-
export SQL_SERVER=$(echo "$DEPLOY_OUTPUT" | jq -r '.sqldB_SERVER.value')
176-
echo "SQL_SERVER=$SQL_SERVER" >> $GITHUB_ENV
168+
export SQL_SERVER_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.sqldB_SERVER_NAME.value')
169+
echo "SQL_SERVER_NAME=$SQL_SERVER_NAME" >> $GITHUB_ENV
177170
export SQL_DATABASE=$(echo "$DEPLOY_OUTPUT" | jq -r '.sqldB_DATABASE.value')
178171
echo "SQL_DATABASE=$SQL_DATABASE" >> $GITHUB_ENV
179172
export CLIENT_ID=$(echo "$DEPLOY_OUTPUT" | jq -r '.managedidentitY_WEBAPP_CLIENTID.value')
@@ -182,8 +175,6 @@ jobs:
182175
echo "CLIENT_NAME=$CLIENT_NAME" >> $GITHUB_ENV
183176
export RG_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.resourcE_GROUP_NAME.value')
184177
echo "RG_NAME=$RG_NAME" >> $GITHUB_ENV
185-
export RESOURCE_GROUP_NAME_FOUNDRY=$(echo "$DEPLOY_OUTPUT" | jq -r '.resourcE_GROUP_NAME_FOUNDRY.value')
186-
echo "RESOURCE_GROUP_NAME_FOUNDRY=$RESOURCE_GROUP_NAME_FOUNDRY" >> $GITHUB_ENV
187178
WEBAPP_URL=$(echo $DEPLOY_OUTPUT | jq -r '.weB_APP_URL.value')
188179
echo "WEBAPP_URL=$WEBAPP_URL" >> $GITHUB_OUTPUT
189180
WEB_APP_NAME=$(echo $DEPLOY_OUTPUT | jq -r '.weB_APP_NAME.value')
@@ -195,9 +186,7 @@ jobs:
195186
196187
sleep 30
197188
198-
199-
200-
- name: Deploy Infra and Import Sample Data
189+
- name: Deploy Infra and Import Sample Data
201190
run: |
202191
set -e
203192
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
@@ -220,10 +209,9 @@ jobs:
220209
"" \
221210
"${{ secrets.AZURE_CLIENT_ID }}" \
222211
"${{ env.RG_NAME }}" \
223-
"${{ env.SQL_SERVER }}" \
224-
"${{ env.AI_FOUNDARY_NAME }}" \
212+
"${{ env.SQL_SERVER_NAME }}" \
225213
"${{ env.SEARCH_SERVICE_NAME }}" \
226-
"${{ env.RESOURCE_GROUP_NAME_FOUNDRY }}"
214+
"${{ env.AI_FOUNDRY_RESOURCE_ID}}"
227215
228216
229217
user_roles_json='[
@@ -232,13 +220,11 @@ jobs:
232220
]'
233221
234222
bash ./infra/scripts/add_user_scripts/create_sql_user_and_role.sh \
235-
"${{ env.SQL_SERVER }}.database.windows.net" \
223+
"${{ env.SQL_SERVER_NAME }}.database.windows.net" \
236224
"${{ env.SQL_DATABASE }}" \
237225
"$user_roles_json" \
238226
"${{ secrets.AZURE_CLIENT_ID }}"
239-
240227
echo "=== Post-Deployment Script Completed Successfully ==="
241-
242228
243229
- name: Get AI Services name and store in variable
244230
if: always() && steps.check_create_rg.outcome == 'success'
@@ -262,7 +248,6 @@ jobs:
262248
run: |
263249
set -e
264250
echo "Listing all KeyVaults in the resource group ${{ env.RESOURCE_GROUP_NAME }}..."
265-
266251
# Get the list of KeyVaults in the specified resource group
267252
keyvaults=$(az resource list --resource-group ${{ env.RESOURCE_GROUP_NAME }} --query "[?type=='Microsoft.KeyVault/vaults'].name" -o tsv)
268253
@@ -288,7 +273,6 @@ jobs:
288273
# Output the formatted array and save it to the job output
289274
echo "KEYVAULTS=$keyvault_array" >> $GITHUB_OUTPUT
290275
fi
291-
292276
- name: Set Deployment Status
293277
id: deployment_status
294278
if: always()
@@ -312,7 +296,7 @@ jobs:
312296
secrets: inherit
313297

314298
cleanup:
315-
if: always()
299+
if: always()
316300
needs: [deploy, e2e-test]
317301
runs-on: ubuntu-latest
318302
env:
@@ -336,12 +320,10 @@ jobs:
336320
set -e
337321
echo "Checking if resource group exists..."
338322
echo "Resource group name: ${{ env.RESOURCE_GROUP_NAME }}"
339-
340323
if [ -z "${{ env.RESOURCE_GROUP_NAME }}" ]; then
341324
echo "Resource group name is empty. Skipping deletion."
342325
exit 0
343326
fi
344-
345327
rg_exists=$(az group exists --name "${{ env.RESOURCE_GROUP_NAME }}")
346328
if [ "$rg_exists" = "true" ]; then
347329
echo "Resource group exists. Cleaning..."
@@ -368,12 +350,9 @@ jobs:
368350
369351
# Remove the surrounding square brackets and quotes, if they exist
370352
stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g' | sed 's/"//g')
371-
372353
# Convert the comma-separated string into an array
373354
IFS=',' read -r -a resources_to_check <<< "$stripped_keyvaults"
374-
375355
echo "List of resources to check: ${resources_to_check[@]}"
376-
377356
# Check if resource group still exists before listing resources
378357
rg_exists=$(az group exists --name "${{ env.RESOURCE_GROUP_NAME }}")
379358
if [ "$rg_exists" = "false" ]; then
@@ -472,7 +451,6 @@ jobs:
472451
473452
# Remove the surrounding square brackets and quotes, if they exist
474453
stripped_keyvaults=$(echo "$KEYVAULTS" | sed 's/\[\|\]//g' | sed 's/"//g')
475-
476454
# Convert the comma-separated string into an array
477455
IFS=',' read -r -a keyvault_array <<< "$stripped_keyvaults"
478456
@@ -506,15 +484,13 @@ jobs:
506484
if: failure() || needs.deploy.result == 'failure' || needs.e2e-test.result == 'failure'
507485
run: |
508486
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
509-
510487
# Construct the email body
511488
EMAIL_BODY=$(cat <<EOF
512489
{
513490
"body": "<p>Dear Team,</p><p>We would like to inform you that the Build-your-own-copilot-Solution-Accelerator(Client Advisior) 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>"
514491
}
515492
EOF
516493
)
517-
518494
# Send the notification
519495
curl -X POST "${{ secrets.LOGIC_APP_URL }}" \
520496
-H "Content-Type: application/json" \

docs/CustomizingAzdParameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ By default this template will use the environment name as the prefix to prevent
1818
| `AZURE_ENV_EMBEDDING_MODEL_NAME` | string | `text-embedding-ada-002` | Set the model name used for embeddings. |
1919
| `AZURE_ENV_EMBEDDING_MODEL_CAPACITY` | integer | `80` | Set the capacity for embedding model deployment. |
2020
| `AZURE_ENV_IMAGETAG` | string | `latest` | Set the image tag (allowed values: `latest`, `dev`, `hotfix`). |
21-
| `AZURE_LOCATION` | string | `japaneast` | Sets the Azure region for resource deployment. |
21+
| `AZURE_LOCATION` | string | `<User selects during deployment>` | Sets the Azure region for resource deployment. |
2222
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | Guide to get your [Existing Workspace ID](/docs/re-use-log-analytics.md) | Reuses an existing Log Analytics Workspace instead of provisioning a new one. |
2323
| `AZURE_EXISTING_AI_PROJECT_RESOURCE_ID` | string | `<Existing AI Foundry Project Resource Id>` | Reuses an existing AI Foundry Project Resource Id instead of provisioning a new one. |
2424

docs/DeploymentGuide.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ When you start the deployment, most parameters will have **default values**, but
116116
| **Embedding Model Capacity** | Set the capacity for **embedding models**. Choose based on usage and quota. | `80` |
117117
| **Image Tag** | The version of the Docker image to use (e.g., `latest`, `dev`, `hotfix`). | `latest` |
118118
| **Azure OpenAI API Version** | Set the API version for OpenAI model deployments. | `2025-04-01-preview` |
119-
| **AZURE\_LOCATION** | Sets the Azure region for resource deployment. | `japaneast` |
119+
| **AZURE_LOCATION** | Sets the Azure region for resource deployment. | `<User selects during deployment>` |
120120
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(empty)* |
121121
| **Existing AI Foundry Project Resource ID** | To reuse an existing AI Foundry Project Resource ID instead of creating a new one. | *(empty)* |
122122

@@ -143,6 +143,13 @@ To adjust quota settings, follow these [steps](./AzureGPTQuotaSettings.md).
143143

144144
Guide to get your [Existing Workspace ID](/docs/re-use-log-analytics.md)
145145

146+
</details>
147+
<details>
148+
149+
<summary><b>Reusing an Existing Azure AI Foundry Project</b></summary>
150+
151+
Guide to get your [Existing Project ID](/docs/re-use-foundry-project.md)
152+
146153
</details>
147154

148155
### Deploying with AZD

docs/LocalSetupAndDeploy.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ Navigate to the `App` folder located in the `src` directory of the repository us
1313

1414
### 2. Configure Environment Variables
1515
- Copy the `.env.sample` file to a new file named `.env`.
16-
- Update the `.env` file with the required values from your Azure resource group.
16+
- Update the `.env` file with the required values from your Azure resource group in Azure Portal App Service environment variables.
17+
- Alternatively, if resources were
18+
provisioned using `azd provision` or `azd up`, a `.env` file is automatically generated in the `.azure/<env-name>/.env`
19+
file. To get your `<env-name>` run `azd env list` to see which env is default.
1720

1821
### 3. Start the Application
1922
- Run `start.cmd` (Windows) or `start.sh` (Linux/Mac) to:
331 KB
Loading
94.9 KB
Loading
196 KB
Loading

docs/re-use-foundry-project.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[← Back to *DEPLOYMENT* guide](/docs/DeploymentGuide.md#deployment-options--steps)
2+
3+
# Reusing an Existing Azure AI Foundry Project
4+
To configure your environment to use an existing Azure AI Foundry Project, follow these steps:
5+
---
6+
### 1. Go to Azure Portal
7+
Go to https://portal.azure.com
8+
9+
### 2. Search for Azure AI Foundry
10+
In the search bar at the top, type "Azure AI Foundry" and click on it. Then select the Foundry service instance where your project exists.
11+
12+
![alt text](../docs/images/re_use_foundry_project/azure_ai_foundry_list.png)
13+
14+
### 3. Navigate to Projects under Resource Management
15+
On the left sidebar of the Foundry service blade:
16+
17+
- Expand the Resource Management section
18+
- Click on Projects (this refers to the active Foundry project tied to the service)
19+
20+
### 4. Click on the Project
21+
From the Projects view: Click on the project name to open its details
22+
23+
Note: You will see only one project listed here, as each Foundry service maps to a single project in this accelerator
24+
25+
![alt text](../docs/images/re_use_foundry_project/navigate_to_projects.png)
26+
27+
### 5. Copy Resource ID
28+
In the left-hand menu of the project blade:
29+
30+
- Click on Properties under Resource Management
31+
- Locate the Resource ID field
32+
- Click on the copy icon next to the Resource ID value
33+
34+
![alt text](../docs/images/re_use_foundry_project/project_resource_id.png)
35+
36+
### 6. Set the Foundry Project Resource ID in Your Environment
37+
Run the following command in your terminal
38+
```bash
39+
azd env set AZURE_EXISTING_AI_PROJECT_RESOURCE_ID '<Existing AI Project Resource ID>'
40+
```
41+
Replace `<Existing AI Project Resource ID>` with the value obtained from Step 5.
42+
43+
### 7. Continue Deployment
44+
Proceed with the next steps in the [deployment guide](/documents/DeploymentGuide.md#deployment-options--steps).

infra/core/database/cosmos/cosmos-role-assign.bicep

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
metadata description = 'Creates a SQL role assignment under an Azure Cosmos DB account.'
2+
3+
@description('Required. Name of the Azure Cosmos DB account.')
24
param accountName string
35

6+
@description('Required. ID of the Cosmos DB SQL role definition.')
47
param roleDefinitionId string
8+
9+
@description('Otional. Principal ID to assign the role to.')
510
param principalId string = ''
611

712
resource role 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-05-15' = {

infra/core/database/cosmos/deploy_cosmos_db.bicep

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
@minLength(3)
2-
@maxLength(15)
3-
@description('Solution Name')
1+
2+
@description('Required. Name of the solution.')
43
param solutionName string
4+
5+
@description('Required. Deployment location for the solution.')
56
param solutionLocation string
67

7-
@description('Name')
8-
param accountName string = '${ solutionName }-cosmos'
8+
@description('Otional. Name of the Cosmos DB account.')
9+
param accountName string = '${solutionName}-cosmos'
10+
11+
@description('Otional. Name of the Cosmos DB database.')
912
param databaseName string = 'db_conversation_history'
13+
14+
@description('Otional. Name of the Cosmos DB container.')
1015
param collectionName string = 'conversations'
1116

17+
@description('Otional. List of Cosmos DB containers to be created.')
1218
param containers array = [
1319
{
1420
name: collectionName
@@ -17,9 +23,11 @@ param containers array = [
1723
}
1824
]
1925

26+
@description('Otional. API kind of the Cosmos DB account.')
2027
@allowed([ 'GlobalDocumentDB', 'MongoDB', 'Parse' ])
2128
param kind string = 'GlobalDocumentDB'
2229

30+
@description('Otional. Resource tags to apply.')
2331
param tags object = {}
2432

2533
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2022-08-15' = {
@@ -68,6 +76,7 @@ resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2022-05-15
6876
]
6977
}
7078

79+
@description('Details of the Cosmos DB account, database, and container.')
7180
output cosmosOutput object = {
7281
cosmosAccountName: cosmos.name
7382
cosmosDatabaseName: databaseName

0 commit comments

Comments
 (0)