Skip to content

Commit 0b6b7ad

Browse files
Pavan-MicrosoftRoopan-MicrosoftAjitPadhi-Microsoftross-p-smithgpickett
authored
fix: resolve team integration citation, BYOD flow, and pipeline issues (#1927)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Roopan-Microsoft <[email protected]> Co-authored-by: Ajit Padhi <[email protected]> Co-authored-by: Roopan P M <[email protected]> Co-authored-by: Ross Smith <[email protected]> Co-authored-by: gpickett <[email protected]> Co-authored-by: Francia Riesco <[email protected]> Co-authored-by: Francia Riesco <[email protected]> Co-authored-by: Prajwal D C <[email protected]> Co-authored-by: Harmanpreet-Microsoft <[email protected]> Co-authored-by: UtkarshMishra-Microsoft <[email protected]> Co-authored-by: Priyanka-Microsoft <[email protected]> Co-authored-by: Prasanjeet-Microsoft <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kiran-Siluveru-Microsoft <[email protected]> Co-authored-by: Prashant-Microsoft <[email protected]> Co-authored-by: Rohini-Microsoft <[email protected]> Co-authored-by: Avijit-Microsoft <[email protected]> Co-authored-by: RaviKiran-Microsoft <[email protected]> Co-authored-by: Somesh Joshi <[email protected]> Co-authored-by: Himanshi Agrawal <[email protected]> Co-authored-by: pradeepjha-microsoft <[email protected]> Co-authored-by: Harmanpreet Kaur <[email protected]> Co-authored-by: Bangarraju-Microsoft <[email protected]> Co-authored-by: Harsh-Microsoft <[email protected]> Co-authored-by: Kanchan-Microsoft <[email protected]> Co-authored-by: Cristopher Coronado <[email protected]> Co-authored-by: Cristopher Coronado Moreira <[email protected]> Co-authored-by: Vamshi-Microsoft <[email protected]> Co-authored-by: Thanusree-Microsoft <[email protected]> Co-authored-by: Niraj Chaudhari (Persistent Systems Inc) <[email protected]> Co-authored-by: Rohini-Microsoft <[email protected]> Co-authored-by: Kingshuk-Microsoft <[email protected]>
1 parent 3c3e4d9 commit 0b6b7ad

34 files changed

+492
-240
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ jobs:
2525
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
2626
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
2727
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
28+
PRINCIPAL_ID: ${{ secrets.PRINCIPAL_ID }}
29+
PRINCIPAL_NAME: ${{ secrets.PRINCIPAL_NAME }}
30+
PRINCIPAL_TYPE: 'ServicePrincipal'
2831

2932
outputs:
3033
imageTag: ${{ steps.set-image-tag.outputs.imageTag }}
3134
web_url: ${{ steps.extract-urls.outputs.web_url }}
3235
admin_url: ${{ steps.extract-urls.outputs.admin_url }}
3336
DEPLOYMENT_SUCCESS: ${{ steps.final-status.outputs.DEPLOYMENT_SUCCESS }}
37+
resource_group: ${{ steps.check_create_rg.outputs.RESOURCE_GROUP_NAME }}
38+
solution_suffix: ${{ steps.generate_solution_prefix.outputs.SOLUTION_SUFFIX }}
3439

3540
steps:
3641
- name: Checkout code
@@ -50,7 +55,7 @@ jobs:
5055
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
5156
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
5257
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
53-
export GPT_MIN_CAPACITY="30"
58+
export GPT_MIN_CAPACITY="150"
5459
export TEXT_EMBEDDING_MIN_CAPACITY="30"
5560
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"
5661
@@ -105,7 +110,7 @@ jobs:
105110
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
106111
if [ "$rg_exists" = "false" ]; then
107112
echo "Resource group does not exist. Creating..."
108-
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ env.AZURE_LOCATION }} --tags SecurityControl=Ignore || { echo "Error creating resource group"; exit 1; }
113+
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ env.AZURE_LOCATION }} --tags SecurityControl=Ignore CreatedBy="Pipeline" || { echo "Error creating resource group"; exit 1; }
109114
else
110115
echo "Resource group already exists."
111116
fi
@@ -203,6 +208,9 @@ jobs:
203208
DISABLE_AUTHENTICATION=true
204209
NO_AUTH=true
205210
SKIP_AUTH=true
211+
PRINCIPAL_ID
212+
PRINCIPAL_NAME
213+
PRINCIPAL_TYPE
206214
207215
- name: Extract URLs from deployment
208216
id: extract-urls
@@ -299,8 +307,6 @@ jobs:
299307
300308
echo "=== PostgreSQL Configuration Summary ==="
301309
echo "Host Endpoint: $PG_HOST_DESTINATION"
302-
echo "Username: admintest (hardcoded)"
303-
echo "Password: Initial_0524 (hardcoded)"
304310
echo "Database: postgres (hardcoded)"
305311
echo "Port: 5432 (hardcoded)"
306312
@@ -311,19 +317,28 @@ jobs:
311317

312318
- name: Install Python dependencies
313319
run: |
314-
pip install psycopg2-binary python-dotenv
315-
320+
pip install psycopg2-binary python-dotenv azure-identity
316321
317322
- name: Populate PostgreSQL Database
318323
run: |
319324
python - <<EOF
320325
import os
321326
import psycopg2
327+
from azure.identity import ClientSecretCredential
328+
329+
tenant_id = os.environ["AZURE_TENANT_ID"]
330+
client_id = os.environ["AZURE_CLIENT_ID"]
331+
client_secret = os.environ["AZURE_CLIENT_SECRET"]
332+
pg_host = os.environ.get("PG_HOST_DESTINATION", "localhost")
333+
334+
# Acquire Azure AD access token for PostgreSQL
335+
credential = ClientSecretCredential(tenant_id, client_id, client_secret)
336+
token = credential.get_token("https://ossrdbms-aad.database.windows.net/.default").token
322337
323338
db_params = {
324-
"user": "admintest",
325-
"password": "Initial_0524",
326-
"host": os.environ.get("PG_HOST_DESTINATION", "localhost"),
339+
"user": client_id, # Use service principal clientId
340+
"password": token, # Use AAD token instead of password
341+
"host": pg_host,
327342
"port": "5432",
328343
"dbname": "postgres",
329344
"sslmode": "require"
@@ -343,8 +358,10 @@ jobs:
343358
except Exception as e:
344359
print(f"❌ Error during import: {e}")
345360
EOF
346-
347-
361+
env:
362+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
363+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
364+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
348365

349366
- name: Final Status Check
350367
id: final-status
@@ -386,9 +403,10 @@ jobs:
386403
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
387404
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
388405
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
389-
AZURE_ENV_NAME: ${{ github.run_id }}
406+
AZURE_ENV_NAME: ${{ needs.deploy.outputs.solution_suffix }} # Get from deploy job
390407
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
391408
imageTag: ${{ needs.deploy.outputs.imageTag }}
409+
AZURE_RESOURCE_GROUP: ${{ needs.deploy.outputs.resource_group }}
392410

393411
steps:
394412
- name: Checkout code
@@ -408,6 +426,7 @@ jobs:
408426
AZURE_SUBSCRIPTION_ID
409427
AZURE_ENV_NAME
410428
AZURE_LOCATION
429+
AZURE_RESOURCE_GROUP
411430
412431
- name: Send Notification on Failure
413432
if: failure()

.github/workflows/create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
workflow_run:
3-
workflows: ["CI"]
3+
workflows: ["Validate Deployment"]
44
types:
55
- completed
66

Makefile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ azd-login: ## 🔑 Login to Azure with azd and a SPN
5757
@echo -e "\e[34m$@\e[0m" || true
5858
@azd auth login --client-id ${AZURE_CLIENT_ID} --client-secret ${AZURE_CLIENT_SECRET} --tenant-id ${AZURE_TENANT_ID}
5959

60-
azd-login: ## 🔑 Login to Azure with azd and a SPN
61-
@echo -e "\e[34m$@\e[0m" || true
62-
@azd auth login --client-id ${AZURE_CLIENT_ID} --client-secret ${AZURE_CLIENT_SECRET} --tenant-id ${AZURE_TENANT_ID}
63-
64-
# Fixed Makefile section for deploy target
6560
# Fixed Makefile section for deploy target
6661
deploy: azd-login ## Deploy everything to Azure
6762
@echo -e "\e[34m$@\e[0m" || true
@@ -126,15 +121,10 @@ deploy: azd-login ## Deploy everything to Azure
126121
echo "$$PG_HOST_VAL" > pg_host.txt
127122

128123

129-
130-
131-
132124
@echo "=== PostgreSQL Configuration ==="
133-
@echo "Username: admintest (hardcoded)"
134125
@echo "Database: postgres (hardcoded)"
135126
@echo "Port: 5432 (hardcoded)"
136127
@echo "Host: $$(cat pg_host.txt 2>/dev/null || echo 'Not available')"
137-
@echo "Password: Initial_0524 (hardcoded)"
138128

139129
# Helper target to check current authentication status
140130
check-auth:
@@ -178,4 +168,5 @@ disable-auth-fixed:
178168

179169
destroy: azd-login ## 🧨 Destroy everything in Azure
180170
@echo -e "\e[34m$@\e[0m" || true
171+
@azd env select $(AZURE_ENV_NAME) || true
181172
@azd down --force --purge --no-prompt

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ To review Cosmos DB configuration overview and steps, follow the link [here](doc
188188
<br/>To ensure sufficient quota is available in your subscription, please follow [quota check instructions guide](./docs/QuotaCheck.md) before you deploy the solution.
189189
190190
<br/>
191-
The "Deploy to Azure" button offers a one-click deployment where you don’t have to clone the code. If you would like a developer experience instead, follow the [local deployment instructions](./docs/LOCAL_DEPLOYMENT.md).
191+
192+
The "Deploy to Azure" button offers a one-click deployment where you don’t have to clone the code. If you would like a developer experience instead, follow the [local deployment instructions](./docs/LOCAL_DEPLOYMENT.md)
192193

193194
Once you deploy to Azure, you will have the option to select PostgreSQL or Cosmos DB, see screenshot below.
194195

@@ -205,6 +206,23 @@ locations support this version. If you're deploying to a location that doesn't s
205206
switch to a lower version. To find out which versions are supported in different regions, visit the
206207
[GPT-4.1 Model Availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#global-standard-model-availability) page.
207208

209+
210+
### Supported Azure Regions
211+
212+
The solution has been tested and is compatible with the following Azure regions:
213+
- **Australia East**
214+
- **East US 2**
215+
- **Japan East**
216+
- **UK South**
217+
218+
These regions are specifically configured in the deployment template to guarantee compatibility with paired regions and data redundancy. This restriction ensures reliable failover scenarios based on Azure's region availability and the requirements of services like Azure Database for PostgreSQL Flexible Server.
219+
220+
When deploying the solution using the "Deploy to Azure" button, you'll see two fields in the Azure portal:
221+
- **Region**: This refers to the Azure region where the deployment metadata is stored
222+
- **Location**: This corresponds to the "location" parameter in the bicep template and determines where all your solution resources will be deployed
223+
224+
**Important**: For this solution, you must select one of the supported regions listed above in the "Location" field. The "Region" field can be set to any available region since it only affects deployment metadata storage.
225+
208226
### Testing the deployment
209227
1. Navigate to the admin site, where you can upload documents. It will be located at:
210228

azure.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
name: chat-with-your-data-solution-accelerator
44
metadata:
55
6+
7+
requiredVersions:
8+
azd: '>= 1.18.0'
9+
610
hooks:
711
postprovision:
812
# run: ./infra/prompt-flow/create-prompt-flow.sh
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import logging
2+
import azure.functions as func
3+
import json
4+
5+
bp_combine_pages_and_chunknos = func.Blueprint()
6+
7+
8+
@bp_combine_pages_and_chunknos.route(route="combine_pages_and_chunknos", methods=["POST"], auth_level=func.AuthLevel.ANONYMOUS)
9+
def combine_pages_and_chunknos(req: func.HttpRequest) -> func.HttpResponse:
10+
"""
11+
This function is designed to be called by an Azure Cognitive Search WebApiSkill.
12+
It expects a JSON payload with two arrays ("pages" and "chunk_nos") and
13+
combines them into a single array of objects.
14+
"""
15+
logging.info("Combine pages and chunk numbers function processed a request.")
16+
17+
try:
18+
req_body = req.get_json()
19+
values = req_body.get("values", [])
20+
21+
response_values = []
22+
23+
for value in values:
24+
record_id = value.get("recordId")
25+
data = value.get("data", {})
26+
27+
pages = data.get("pages", [])
28+
chunk_nos = data.get("chunk_nos", [])
29+
30+
# Zip the two arrays together
31+
zipped_data = [
32+
{"page_text": page, "chunk_no": chunk}
33+
for page, chunk in zip(pages, chunk_nos)
34+
]
35+
36+
response_values.append(
37+
{
38+
"recordId": record_id,
39+
"data": {"pages_with_chunks": zipped_data},
40+
"errors": None,
41+
"warnings": None,
42+
}
43+
)
44+
45+
# Return the response in the format expected by the WebApiSkill
46+
return func.HttpResponse(
47+
body=json.dumps({"values": response_values}),
48+
mimetype="application/json",
49+
status_code=200,
50+
)
51+
52+
except Exception as e:
53+
logging.error(f"Error in combine_pages_and_chunknos function: {e}")
54+
return func.HttpResponse(
55+
body=json.dumps({"values": [{"recordId": "error", "data": {}, "errors": [{"message": str(e)}], "warnings": []}]}),
56+
mimetype="application/json",
57+
status_code=500,
58+
)

code/backend/batch/function_app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from batch_push_results import bp_batch_push_results
66
from batch_start_processing import bp_batch_start_processing
77
from get_conversation_response import bp_get_conversation_response
8+
from combine_pages_chunknos import bp_combine_pages_and_chunknos
89
from azure.monitor.opentelemetry import configure_azure_monitor
910

1011
logging.captureWarnings(True)
@@ -20,3 +21,4 @@
2021
app.register_functions(bp_batch_push_results)
2122
app.register_functions(bp_batch_start_processing)
2223
app.register_functions(bp_get_conversation_response)
24+
app.register_functions(bp_combine_pages_and_chunknos)

code/backend/batch/utilities/integrated_vectorization/azure_search_indexer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from azure.search.documents.indexes.models import SearchIndexer, FieldMapping
2+
from azure.search.documents.indexes.models import SearchIndexer, FieldMapping, FieldMappingFunction
33
from azure.search.documents.indexes import SearchIndexerClient
44
from ..helpers.env_helper import EnvHelper
55
from ..helpers.azure_credential_utils import get_azure_credential
@@ -35,6 +35,13 @@ def create_or_update_indexer(self, indexer_name: str, skillset_name: str):
3535
}
3636
},
3737
field_mappings=[
38+
FieldMapping(
39+
source_field_name="metadata_storage_path",
40+
target_field_name="id",
41+
mapping_function=FieldMappingFunction(
42+
name="base64Encode", parameters={"useHttpServerUtilityUrlTokenEncode": False}
43+
)
44+
),
3845
FieldMapping(
3946
source_field_name="metadata_storage_path",
4047
target_field_name="source",

0 commit comments

Comments
 (0)