Skip to content
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
2dbb0b1
ci: Updated workflow to handle main, dev and demo branch | Dependabot…
Roopan-Microsoft Nov 25, 2024
97ced9f
fix: SFI Fixes & scope reverted to subscription (#1513)
Roopan-Microsoft Nov 25, 2024
903c259
ci: workflow updated for build docker (#1514)
Roopan-Microsoft Nov 25, 2024
4cf2972
ci: build docker updated for dev (#1522)
Roopan-Microsoft Nov 25, 2024
9158819
ci: workflow branch code updated (#1525)
Roopan-Microsoft Nov 25, 2024
4545a48
updated comment
AjitPadhi-Microsoft Nov 25, 2024
84a33b5
updated workflow
AjitPadhi-Microsoft Nov 25, 2024
f8c1c8f
updated workflow
AjitPadhi-Microsoft Nov 25, 2024
e31a661
updated workflow
AjitPadhi-Microsoft Nov 26, 2024
847ce7e
updated bicep for registry
AjitPadhi-Microsoft Nov 26, 2024
8f8cc98
fixed bicep
AjitPadhi-Microsoft Nov 26, 2024
15b948c
fix: bicep updated (#1527)
AjitPadhi-Microsoft Nov 26, 2024
1645e43
Merge branch 'main' into dev
Roopan-Microsoft Nov 27, 2024
8df387a
Merge branch 'dev' of https://github.com/Azure-Samples/chat-with-your…
Roopan-Microsoft Nov 27, 2024
e4dd5f2
fix: Container issue fix for multiple branch (#1539)
AjitPadhi-Microsoft Nov 27, 2024
88d06dc
fix: Updated workflow (#1540)
AjitPadhi-Microsoft Nov 27, 2024
e5cf4dd
ci: Psl container fix for checkout code from head branch (#1541)
Roopan-Microsoft Nov 27, 2024
02d0056
fix: multiple container tag issue fix (#1552)
AjitPadhi-Microsoft Dec 9, 2024
90e1040
fix: Workflow issue fix on docker image (#1554)
AjitPadhi-Microsoft Dec 9, 2024
8a5a1cb
fix: Downmerge dev (#1566)
Pavan-Microsoft Dec 18, 2024
131c323
fix: CWYD Citation Links to Documents Break After Specific Timeframe …
Harmanpreet-Microsoft Dec 18, 2024
93b84ed
fix: Commit changes bug (#1568)
UtkarshMishra-Microsoft Dec 18, 2024
0875b92
fix: Post-Deployment Script for Managing Bicep Outputs in .env File …
Pavan-Microsoft Dec 19, 2024
76190b3
fix: import error in env_helper.py (#1571)
Pavan-Microsoft Dec 19, 2024
c65bf01
fix: add conversation flow in environment variable for adminweb app (…
Priyanka-Microsoft Dec 19, 2024
1f326d9
fix: Update Hosting Model Configuration in ARM/Bicep Template (#1570)
Prasanjeet-Microsoft Dec 19, 2024
fc688c2
fix: Update main.json for changes conversation flow changes in bicep …
Priyanka-Microsoft Dec 19, 2024
56adb59
Merge branch 'main' into dev
Roopan-Microsoft Dec 24, 2024
afaabdc
build: Dependabotchanges merge to Dev branch (#1602)
Roopan-Microsoft Dec 30, 2024
03f52b3
feat: Configurable System Prompts for Flexibility and Maintenance - C…
Pavan-Microsoft Dec 31, 2024
e92eba1
fix: Add Missing Logs (#1609)
Pavan-Microsoft Jan 2, 2025
b0860ee
commented the prompt flow in azure yaml file
Roopan-Microsoft Jan 3, 2025
983b1f7
Merge branches 'dev' and 'dev' of https://github.com/Azure-Samples/ch…
Roopan-Microsoft Jan 3, 2025
dae4043
Add execute permissions parse_env.sh in postprovision hook
Pavan-Microsoft Jan 3, 2025
08ad207
fix: Build issue with docker
Prajwal-Microsoft Jan 4, 2025
c49ddfd
Update build-docker.yml
Prajwal-Microsoft Jan 5, 2025
5994f99
fix: Docker file failure issue
Prajwal-Microsoft Jan 5, 2025
dc7b87c
fix: Response getting ']' brackets, it's inconsistent (#1611)
AjitPadhi-Microsoft Jan 6, 2025
2d1af79
fix: Fix Duplication of Flattened JSON Keys in .env File During Multi…
Pavan-Microsoft Jan 7, 2025
c553312
fix: Role Duplication Error in azd up Command for PostgreSQL (#1621)
Pavan-Microsoft Jan 10, 2025
8213f0a
Merge branch 'main' into dev
Roopan-Microsoft Jan 10, 2025
1f22786
feat: Remove AI search service for PostgreSQL configuration to optimi…
Prasanjeet-Microsoft Jan 13, 2025
7c2391c
feat: Implement Consistent Versioning and Tagging for Accelerator Ima…
Pavan-Microsoft Jan 15, 2025
8393614
Merge branch 'main' into dev
Roopan-Microsoft Jan 20, 2025
3789d45
fix: Warning message displayed twice in chat history update (#1630)
Pavan-Microsoft Jan 24, 2025
699dff8
test: unit test cases changes (#1353)
Kiran-Siluveru-Microsoft Jan 28, 2025
461779f
Update default.json
Roopan-Microsoft Feb 6, 2025
e0be943
Update default_contract_assistant_prompt.txt
Roopan-Microsoft Feb 6, 2025
f28ddc6
Update open_ai_functions.py
Roopan-Microsoft Feb 6, 2025
63ec389
Update build-docker.yml
Roopan-Microsoft Feb 6, 2025
e1d37f1
Update create_app.py
Roopan-Microsoft Feb 6, 2025
ec42447
Update test_conversation.py
Roopan-Microsoft Feb 6, 2025
86dd916
Update test_iv_question_answer_tool.py
Roopan-Microsoft Feb 6, 2025
b1f2615
Update test_response_with_search_documents_tool.py
Roopan-Microsoft Feb 6, 2025
3431205
Update test_conversation_flow.py
Roopan-Microsoft Feb 6, 2025
7025c6e
ci: update docker registry logic for main, dev, and demo branches (#1…
Priyanka-Microsoft Feb 7, 2025
8fca481
fix: Updates to change the Azure OpenAI model from `gpt-35-turbo` to …
Roopan-Microsoft Feb 13, 2025
18e1dca
docs: updated numerical queries section in best practices readme (#1670)
Harsh-Microsoft Feb 17, 2025
c13b4e3
Merge branch 'main' into dev
Roopan-Microsoft Feb 17, 2025
1ed3f43
fix: Admin configuration issue fix (#1676)
AjitPadhi-Microsoft Feb 18, 2025
f083af8
Merge branch 'main' into dev
Roopan-Microsoft Feb 19, 2025
32ebef3
build: Merge Dependabot Changes into Dev Branch (#1679)
Prasanjeet-Microsoft Feb 28, 2025
2803e48
Merge branch 'main' into dev
Roopan-Microsoft Mar 3, 2025
b5f35ac
Package lock updated
Roopan-Microsoft Mar 3, 2025
0b01abb
Merge remote-tracking branch 'origin/main' into dev
Prajwal-Microsoft Mar 4, 2025
21b57da
docs: Added migration readme file (#1668)
Priyanka-Microsoft Mar 4, 2025
6f30b3f
refactor: enforcing authentication based on environment variable "ENF…
Harsh-Microsoft Mar 24, 2025
9de26fd
build: Merge Dependabot Changes into Dev Branch (#1749)
Prasanjeet-Microsoft Apr 11, 2025
f7a2ce9
chore: Update Azure OpenAI Vision Model configuration to turbo-2024-0…
Harmanpreet-Microsoft Apr 15, 2025
dc763c2
feat: json document processor (#1661)
cristofima Apr 16, 2025
9664143
fix: Resolve chunking issue during deployment when enabling advanced …
Priyanka-Microsoft Apr 21, 2025
e8382d3
Merge branch 'main' into dev
Roopan-Microsoft May 5, 2025
4f09b12
fix: bug(#1653) added tooltip for chat history items. (#1785)
Bangarraju-Microsoft May 6, 2025
c7f3e8d
build: Add .dockerignore to optimize Docker build context (#1790)
Prasanjeet-Microsoft May 6, 2025
cea820d
fix: Updated reset configuration to use dialog instead of popover whi…
Vamshi-Microsoft May 9, 2025
5d79d5d
refactor: centralize Azure resource naming with abbreviations.json an…
Harmanpreet-Microsoft May 12, 2025
a9d8511
fix: Changed the button label from "Reset Now" to "Reset" (#1796)
Vamshi-Microsoft May 13, 2025
88caa69
Merge branch 'main' into dev
Roopan-Microsoft May 22, 2025
5383461
main json updated
Roopan-Microsoft May 22, 2025
86ebab4
fix: hardcoded abbreviations in bicep (#1805)
Harsh-Microsoft May 22, 2025
03606b7
fix: Enhance Bicep Outputs for Environment Variable Configuration in …
Prasanjeet-Microsoft May 29, 2025
7ae4b79
fix: Add Cosmos DB Account Key Output for Environment Configuration (…
Prasanjeet-Microsoft May 29, 2025
69669bb
fix: error in 'Process and Ingest Web Pages' under 'Add URLs to the K…
Priyanka-Microsoft Jun 2, 2025
464139c
test: Migrate test automation scripts, llm evaluator and pipeline for…
Harsh-Microsoft Jun 3, 2025
27211e9
ci: configuration to include optional arguments for running tests dur…
Harsh-Microsoft Jun 3, 2025
4fec5b7
Merge branch 'main' into dev
Prasanjeet-Microsoft Jun 3, 2025
b3fcae0
test: add citation link interaction support to e2e tests (#1821)
Harmanpreet-Microsoft Jun 4, 2025
f075a9b
chore: update default OpenAI model to gpt-4.1 across codebase and inf…
Harmanpreet-Microsoft Jun 10, 2025
edb03ab
feat: Down merge from dev & resolved conflicts (#1826)
Prajwal-Microsoft Jun 11, 2025
7f4a427
feat: EXP Changes to reuse existing resource group and Log analytics …
Prajwal-Microsoft Jun 11, 2025
74e1d6c
feat: rebuilt main.json
Prajwal-Microsoft Jun 12, 2025
eccd758
Merge branch 'main' into dev
Roopan-Microsoft Jun 16, 2025
fedee97
test: Implement Log execution time per prompt in Report for CWYD (#1832)
Rohini-Microsoft Jun 19, 2025
c5be551
Merge branch 'main' into dev
Roopan-Microsoft Jun 19, 2025
fc4e2a2
feat: Add Broken Link Checker workflow for Markdown files (#1834)
Vamshi-Microsoft Jun 20, 2025
685e56f
fix: add missing 'text' and 'layoutText' fields for Azure Search inte…
Prasanjeet-Microsoft Jun 26, 2025
a9bd530
Merge branch 'main' into dev
Roopan-Microsoft Jun 30, 2025
7435501
main json updated
Roopan-Microsoft Jun 30, 2025
21d3aef
fix: Only support RBAC with authenticate using managed identity (#1857)
AjitPadhi-Microsoft Jul 14, 2025
fc269f5
ci: refactor deployment workflow to include dynamic URL outputs, e2e …
Harmanpreet-Microsoft Jul 14, 2025
400d1f8
fix: Oneclick deployment issue fix (#1859)
AjitPadhi-Microsoft Jul 14, 2025
049836a
fix: Remove Exposed Speech Service API Key from Network Calls (#1869)
Prasanjeet-Microsoft Jul 28, 2025
0bd33ec
fix: onclick deployment issue fix (#1870)
AjitPadhi-Microsoft Jul 29, 2025
59efafe
chore: update Python and JavaScript dependencies for compatibility a…
Harmanpreet-Microsoft Aug 14, 2025
b536feb
Merge branch 'main' into dev
Roopan-Microsoft Aug 18, 2025
c9d4a23
Updated main json file
Roopan-Microsoft Aug 18, 2025
c69198f
refactor: make principal type optional in role assignments and clean …
Harmanpreet-Microsoft Aug 20, 2025
a4e4d4a
Update deploy_create_table_script.bicep
Roopan-Microsoft Aug 21, 2025
2e2be2c
Merge branch 'main' into dev
Roopan-Microsoft Aug 25, 2025
27f34d8
fix: Cosmos&Postgres]- Error during Team integration (#1893)
Rohini-Microsoft Sep 5, 2025
dad4e6e
fix: Fix for Group Dependabot PRs Pipeline failure (#1900)
NirajC-Microsoft Sep 17, 2025
9d86faa
feat: On click of button teatarea should be clear (#1904)
Rohini-Microsoft Sep 22, 2025
aa7a26f
feat: WAF implementation for CWYD (#1916)
Prajwal-Microsoft Sep 23, 2025
52ea704
fix: fix unit testcases (#1918)
Pavan-Microsoft Sep 24, 2025
4925b3b
ci: update image tags to use 'latest_waf' for Docker builds and deplo…
Harsh-Microsoft Sep 24, 2025
2b28e45
fix: Pipeline issue for deploy & build (#1919)
Prajwal-Microsoft Sep 24, 2025
de608a2
fix: Updated accelerator name
Prajwal-Microsoft Sep 24, 2025
da653ef
fix: Updated the default token limit
Prajwal-Microsoft Sep 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/python:3.11
FROM mcr.microsoft.com/devcontainers/python:3.11-bookworm

# install git
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
context: .
file: ${{ inputs.dockerfile }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || github.head_ref || github.ref_name }}
cache-from: type=registry,ref=${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ github.ref_name == 'main' && 'latest_waf' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || github.head_ref || github.ref_name }}
tags: |
${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || github.head_ref || 'default' }}
${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ steps.date.outputs.date }}_${{ github.run_number }}
${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ github.ref_name == 'main' && 'latest_waf' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || github.head_ref || 'default' }}
${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ github.ref_name == 'main' && 'latest_waf' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || github.head_ref || 'default' }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
58 changes: 53 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install AZD
run: |
set -e
echo "Fetching deployment output..."
# Install azd (Azure Developer CLI) - required by process_sample_data.sh
curl -fsSL https://aka.ms/install-azd.sh | bash

- name: Run Quota Check
id: quota-check
run: |
Expand Down Expand Up @@ -79,6 +86,45 @@ jobs:
echo "Selected Region: $VALID_REGION"
echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV

- name: Generate Resource Group Name
id: generate_rg_name
run: |
echo "Generating a unique resource group name..."
ACCL_NAME="cwyd" # Account name as specified
SHORT_UUID=$(uuidgen | cut -d'-' -f1)
UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"

- name: Check and Create Resource Group
id: check_create_rg
run: |
echo "RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}"
set -e
echo "Checking if resource group exists..."
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
if [ "$rg_exists" = "false" ]; then
echo "Resource group does not exist. Creating..."
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ env.AZURE_LOCATION }} --tags SecurityControl=Ignore || { echo "Error creating resource group"; exit 1; }
else
echo "Resource group already exists."
fi
# Set output for other jobs
echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT


- name: Generate Unique Solution Prefix
id: generate_solution_prefix
run: |
set -e
COMMON_PART="pslc"
TIMESTAMP=$(date +%s)
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
UNIQUE_SOLUTION_SUFFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
echo "SOLUTION_SUFFIX=${UNIQUE_SOLUTION_SUFFIX}" >> $GITHUB_ENV
echo "SOLUTION_SUFFIX=${UNIQUE_SOLUTION_SUFFIX}" >> $GITHUB_OUTPUT
echo "Generated SOLUTION_SUFFIX: ${UNIQUE_SOLUTION_SUFFIX}"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand All @@ -90,11 +136,11 @@ jobs:
id: set-image-tag
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "imageTag=latest" >> $GITHUB_ENV
echo "::set-output name=imageTag::latest"
echo "imageTag=latest_waf" >> $GITHUB_ENV
echo "::set-output name=imageTag::latest_waf"
elif [[ "${{ github.ref_name }}" == "main" ]]; then
echo "imageTag=latest" >> $GITHUB_ENV
echo "::set-output name=imageTag::latest"
echo "imageTag=latest_waf" >> $GITHUB_ENV
echo "::set-output name=imageTag::latest_waf"
else
echo "imageTag=${{ github.ref_name }}" >> $GITHUB_ENV
echo "::set-output name=imageTag::${{ github.ref_name }}"
Expand All @@ -103,8 +149,9 @@ jobs:
- name: Pre-build image and deploy
uses: devcontainers/[email protected]
env:
AZURE_ENV_NAME: ${{ github.run_id }}
AZURE_ENV_NAME: ${{ env.SOLUTION_SUFFIX }}
AZURE_LOCATION: ${{ env.AZURE_LOCATION }}
AZURE_RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}
with:
push: never
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
Expand Down Expand Up @@ -141,6 +188,7 @@ jobs:
AZURE_SUBSCRIPTION_ID
AZURE_ENV_NAME
AZURE_LOCATION
AZURE_RESOURCE_GROUP
AUTH_ENABLED=false
AZURE_USE_AUTHENTICATION=false
AZURE_ENABLE_AUTH=false
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/group_dependabot_security_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ jobs:
git config --global user.email "[email protected]"

- name: Install required tools
uses: awalsh128/[email protected]
with:
packages: "jq gh"
run: |
sudo apt-get update
sudo apt-get install -y jq gh
shell: bash

- name: Enable strict error handling
shell: bash
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ azd-login: ## 🔑 Login to Azure with azd and a SPN
# Fixed Makefile section for deploy target
deploy: azd-login ## Deploy everything to Azure
@echo -e "\e[34m$@\e[0m" || true
@azd env new ${AZURE_ENV_NAME}
@echo "AZURE_ENV_NAME: '${AZURE_ENV_NAME}'"
@echo "AZURE_LOCATION: '${AZURE_LOCATION}'"
@echo "AZURE_RESOURCE_GROUP: '${AZURE_RESOURCE_GROUP}'"

# Validate required variables
@if [ -z "${AZURE_ENV_NAME}" ]; then echo "❌ AZURE_ENV_NAME not set"; exit 1; fi
@if [ -z "${AZURE_LOCATION}" ]; then echo "❌ AZURE_LOCATION not set"; exit 1; fi
@if [ -z "${AZURE_RESOURCE_GROUP}" ]; then echo "❌ AZURE_RESOURCE_GROUP not set"; exit 1; fi

@azd env new ${AZURE_ENV_NAME} --location ${AZURE_LOCATION}
@azd env set AZURE_RESOURCE_GROUP ${AZURE_RESOURCE_GROUP}

# Provision and deploy
@azd provision --no-prompt
Expand Down
2 changes: 1 addition & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

name: chat-with-your-data-solution-accelerator
metadata:
template: [email protected]
template: [email protected]
hooks:
postprovision:
# run: ./infra/prompt-flow/create-prompt-flow.sh
Expand Down
4 changes: 2 additions & 2 deletions code/backend/batch/local.settings.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "",
"AzureWebJobsStorage__accountName": "",
"MyBindingConnection": "",
"AzureWebJobs.HttpExample.Disabled": "true"
},
Expand All @@ -11,4 +11,4 @@
"CORS": "*",
"CORSCredentials": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_conversation_client():
f"https://{env_helper.AZURE_COSMOSDB_ACCOUNT}.documents.azure.com:443/"
)
credential = (
get_azure_credential()
get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID)
if not env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
else env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncpg
from datetime import datetime, timezone
from ..helpers.azure_credential_utils import get_azure_credential
from ..helpers.env_helper import EnvHelper

from .database_client_base import DatabaseClientBase

Expand All @@ -13,6 +14,7 @@ class PostgresConversationClient(DatabaseClientBase):
def __init__(
self, user: str, host: str, database: str, enable_message_feedback: bool = False
):
self.env_helper = EnvHelper()
self.user = user
self.host = host
self.database = database
Expand All @@ -21,7 +23,7 @@ def __init__(

async def connect(self):
try:
credential = get_azure_credential()
credential = get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)
token = credential.get_token(
"https://ossrdbms-aad.database.windows.net/.default"
).token
Expand All @@ -31,7 +33,7 @@ async def connect(self):
database=self.database,
password=token,
port=5432,
ssl="require",
ssl=True,
)
except Exception as e:
logger.error("Failed to connect to PostgreSQL: %s", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_queue_client():
return QueueClient(
account_url=f"https://{env_helper.AZURE_BLOB_ACCOUNT_NAME}.queue.core.windows.net/",
queue_name=env_helper.DOCUMENT_PROCESSING_QUEUE_NAME,
credential=get_azure_credential(),
credential=get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID),
message_encode_policy=BinaryBase64EncodePolicy(),
)

Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(
if self.auth_type == "rbac":
self.account_key = None
self.blob_service_client = BlobServiceClient(
account_url=self.endpoint, credential=get_azure_credential()
account_url=self.endpoint, credential=get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID)
)
self.user_delegation_key = self.request_user_delegation_key(
blob_service_client=self.blob_service_client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, env_helper: EnvHelper) -> None:
self.model_version = (
env_helper.AZURE_COMPUTER_VISION_VECTORIZE_IMAGE_MODEL_VERSION
)
self.managed_identity_client_id = env_helper.MANAGED_IDENTITY_CLIENT_ID

def vectorize_image(self, image_url: str) -> list[float]:
logger.info(f"Making call to computer vision to vectorize image: {image_url}")
Expand Down Expand Up @@ -57,7 +58,7 @@ def __make_request(self, path: str, body) -> Response:
headers["Ocp-Apim-Subscription-Key"] = self.key
else:
token_provider = get_bearer_token_provider(
get_azure_credential(), self.__TOKEN_SCOPE
get_azure_credential(self.managed_identity_client_id), self.__TOKEN_SCOPE
)
headers["Authorization"] = "Bearer " + token_provider()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self) -> None:
if env_helper.AZURE_AUTH_TYPE == "rbac":
self.document_analysis_client = DocumentAnalysisClient(
endpoint=self.AZURE_FORM_RECOGNIZER_ENDPOINT,
credential=get_azure_credential(),
credential=get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID),
headers={
"x-ms-useragent": "chat-with-your-data-solution-accelerator/1.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def _create_search_client(self):
dbname = self.env_helper.POSTGRESQL_DATABASE

# Acquire the access token
credential = get_azure_credential()
credential = get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)
access_token = credential.get_token(
"https://ossrdbms-aad.database.windows.net/.default"
)

# Use the token in the connection string
conn_string = (
f"host={host} user={user} dbname={dbname} password={access_token.token}"
f"host={host} user={user} dbname={dbname} password={access_token.token} sslmode=require"
)
self.conn = psycopg2.connect(conn_string)
logger.info("Connected to Azure PostgreSQL successfully.")
Expand Down
4 changes: 2 additions & 2 deletions code/backend/batch/utilities/helpers/azure_search_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _search_credential(self):
if self.env_helper.is_auth_type_keys():
return AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
else:
return get_azure_credential()
return get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)

def _create_search_client(
self, search_credential: Union[AzureKeyCredential, get_azure_credential]
Expand Down Expand Up @@ -285,7 +285,7 @@ def get_conversation_logger(self):
]

if self.env_helper.AZURE_AUTH_TYPE == "rbac":
credential = get_azure_credential()
credential = get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)
return AzureSearch(
azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE,
azure_search_key=None, # Remove API key
Expand Down
13 changes: 9 additions & 4 deletions code/backend/batch/utilities/helpers/env_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ def __load_config(self, **kwargs) -> None:
self.secretHelper = SecretHelper()

self.LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper()
self.APP_ENV = os.getenv("APP_ENV", "Prod").lower()

# Azure
self.AZURE_SUBSCRIPTION_ID = os.getenv("AZURE_SUBSCRIPTION_ID", "")
self.AZURE_RESOURCE_GROUP = os.getenv("AZURE_RESOURCE_GROUP", "")
self.MANAGED_IDENTITY_CLIENT_ID = os.getenv("MANAGED_IDENTITY_CLIENT_ID", "")
self.MANAGED_IDENTITY_RESOURCE_ID = os.getenv("MANAGED_IDENTITY_RESOURCE_ID", "")

# Azure Search
self.AZURE_SEARCH_SERVICE = os.getenv("AZURE_SEARCH_SERVICE", "")
Expand Down Expand Up @@ -217,7 +220,7 @@ def __load_config(self, **kwargs) -> None:
)

self.AZURE_TOKEN_PROVIDER = get_bearer_token_provider(
get_azure_credential(), "https://cognitiveservices.azure.com/.default"
get_azure_credential(self.MANAGED_IDENTITY_CLIENT_ID), "https://cognitiveservices.azure.com/.default"
)
self.ADVANCED_IMAGE_PROCESSING_MAX_IMAGES = self.get_env_var_int(
"ADVANCED_IMAGE_PROCESSING_MAX_IMAGES", 1
Expand All @@ -234,7 +237,7 @@ def __load_config(self, **kwargs) -> None:
self.AZURE_COMPUTER_VISION_VECTORIZE_IMAGE_MODEL_VERSION = os.getenv(
"AZURE_COMPUTER_VISION_VECTORIZE_IMAGE_MODEL_VERSION", "2023-04-15"
)
self.FUNCTION_KEY = os.getenv("FUNCTION_KEY", "")
self.FUNCTION_KEY = self.secretHelper.get_secret("FUNCTION_KEY")

# Initialize Azure keys based on authentication type and environment settings.
# When AZURE_AUTH_TYPE is "rbac", azure keys are None or an empty string.
Expand All @@ -243,7 +246,6 @@ def __load_config(self, **kwargs) -> None:
self.AZURE_OPENAI_API_KEY = ""
self.AZURE_SPEECH_KEY = None
self.AZURE_COMPUTER_VISION_KEY = None
self.FUNCTION_KEY = self.secretHelper.get_secret("FUNCTION_KEY")
else:
self.AZURE_SEARCH_KEY = self.secretHelper.get_secret("AZURE_SEARCH_KEY")
self.AZURE_OPENAI_API_KEY = self.secretHelper.get_secret(
Expand Down Expand Up @@ -429,8 +431,11 @@ def __init__(self) -> None:
self.USE_KEY_VAULT = os.getenv("USE_KEY_VAULT", "").lower() == "true"
self.secret_client = None
if self.USE_KEY_VAULT:
vault_endpoint = os.environ.get("AZURE_KEY_VAULT_ENDPOINT")
if not vault_endpoint:
raise ValueError("AZURE_KEY_VAULT_ENDPOINT environment variable is required when USE_KEY_VAULT is true")
self.secret_client = SecretClient(
os.environ.get("AZURE_KEY_VAULT_ENDPOINT"), get_azure_credential()
vault_endpoint, get_azure_credential(client_id=os.getenv("MANAGED_IDENTITY_CLIENT_ID", None))
)

def get_secret(self, secret_name: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion code/backend/batch/utilities/helpers/llm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def get_sk_service_settings(self, service: AzureChatCompletion):
def get_ml_client(self):
if not hasattr(self, "_ml_client"):
self._ml_client = MLClient(
get_azure_credential(),
get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID),
self.env_helper.AZURE_SUBSCRIPTION_ID,
self.env_helper.AZURE_RESOURCE_GROUP,
self.env_helper.AZURE_ML_WORKSPACE_NAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from azure.search.documents.indexes.models import (
SearchIndexerDataContainer,
SearchIndexerDataSourceConnection,
SearchIndexerDataUserAssignedIdentity,
)
from azure.search.documents.indexes._generated.models import (
NativeBlobSoftDeleteDeletionDetectionPolicy,
Expand All @@ -19,7 +20,7 @@ def __init__(self, env_helper: EnvHelper):
(
AzureKeyCredential(self.env_helper.AZURE_SEARCH_KEY)
if self.env_helper.is_auth_type_keys()
else get_azure_credential()
else get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)
),
)

Expand All @@ -35,6 +36,13 @@ def create_or_update_datasource(self):
connection_string=connection_string,
container=container,
data_deletion_detection_policy=NativeBlobSoftDeleteDeletionDetectionPolicy(),
identity=(
None
if getattr(self.env_helper, "APP_ENV", "").lower() == "dev"
else SearchIndexerDataUserAssignedIdentity(
user_assigned_identity=self.env_helper.MANAGED_IDENTITY_RESOURCE_ID
)
),
)
self.indexer_client.create_or_update_data_source_connection(
data_source_connection
Expand Down
Loading
Loading