From 7f2e48e3dccc67ac1409445f5117110225dc83b2 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Fri, 25 Apr 2025 16:31:12 +0530 Subject: [PATCH] fix: update setup_env.sh to use sudo for script permissions and removed azure function tools; improve user email retrieval in create_sql_user_and_role.sh; clean up requirements --- .devcontainer/setup_env.sh | 8 +------- .github/workflows/CAdeploy.yml | 2 +- .gitignore | 3 +++ README.md | 2 +- .../add_user_scripts/create_sql_user_and_role.sh | 6 +++++- infra/scripts/index_scripts/create_sql_tables.py | 1 - infra/scripts/index_scripts/requirements.txt | 1 - infra/scripts/run_create_index_scripts.sh | 12 +++++++++++- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.devcontainer/setup_env.sh b/.devcontainer/setup_env.sh index d73f28c3d..b2d7806a9 100755 --- a/.devcontainer/setup_env.sh +++ b/.devcontainer/setup_env.sh @@ -4,7 +4,7 @@ git fetch git pull # provide execute permission to quotacheck script -chmod +x ./infra/scripts/checkquota.sh +sudo chmod +x ./infra/scripts/checkquota.sh # Add the path to ~/.bashrc for persistence if ! grep -q '/opt/mssql-tools18/bin' ~/.bashrc; then @@ -20,9 +20,3 @@ if ! command -v sqlcmd &> /dev/null; then exit 1 fi -# Install Azure function core tool -wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -sudo dpkg -i packages-microsoft-prod.deb - -sudo apt-get update -sudo apt-get install azure-functions-core-tools-4 diff --git a/.github/workflows/CAdeploy.yml b/.github/workflows/CAdeploy.yml index c29837d9c..03ab12f99 100644 --- a/.github/workflows/CAdeploy.yml +++ b/.github/workflows/CAdeploy.yml @@ -115,7 +115,7 @@ jobs: az deployment group create \ --resource-group ${{ env.RESOURCE_GROUP_NAME }} \ --template-file infra/main.bicep \ - --parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} cosmosLocation=${{ env.AZURE_LOCATION }} + --parameters AZURE_ENV_OPENAI_LOCATION=${{ env.AZURE_LOCATION }} - name: List KeyVaults and Store in Array id: list_keyvaults diff --git a/.gitignore b/.gitignore index 0b41d241c..f223f792e 100644 --- a/.gitignore +++ b/.gitignore @@ -401,3 +401,6 @@ FodyWeavers.xsd scriptenv .azure + +clientdata +clienttranscripts \ No newline at end of file diff --git a/README.md b/README.md index 71571abc0..4f182dcf8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Follow the quick deploy steps on the deployment guide to deploy this solution to [Click here to launch the deployment guide](./docs/DeploymentGuide.md) -| [![Open in Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=microsoft/Build-your-own-copilot-Solution-Accelerator&ref=dev) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/Build-your-own-copilot-Solution-Accelerator&ref=dev) | +| [![Open in Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=microsoft/Build-your-own-copilot-Solution-Accelerator) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/Build-your-own-copilot-Solution-Accelerator) | |---|---| > ⚠️ **Important: Check Azure OpenAI Quota Availability**
To ensure sufficient quota is available in your subscription, please follow [quota check instructions guide](./docs/quota_check.md) before you deploy the solution. diff --git a/infra/scripts/add_user_scripts/create_sql_user_and_role.sh b/infra/scripts/add_user_scripts/create_sql_user_and_role.sh index 6eeb3b3ce..65526819c 100644 --- a/infra/scripts/add_user_scripts/create_sql_user_and_role.sh +++ b/infra/scripts/add_user_scripts/create_sql_user_and_role.sh @@ -92,7 +92,11 @@ OS=$(uname | tr '[:upper:]' '[:lower:]') if [[ "$OS" == "mingw"* || "$OS" == "cygwin"* || "$OS" == "msys"* ]]; then echo "Running on Windows OS, will use interactive login" echo "Getting signed in user email" - UserEmail=$(az ad signed-in-user show --query userPrincipalName -o tsv) + UserEmail=$(az ad signed-in-user show --query mail -o tsv) + # If the email is null or empty, use userPrincipalName + if [[ -z "$UserEmail" ]]; then + UserEmail=$(az ad signed-in-user show --query userPrincipalName -o tsv) + fi # Execute the SQL query echo "Executing SQL query..." sqlcmd -S "$SqlServerName" -d "$SqlDatabaseName" -G -U "$UserEmail" -Q "$SQL_QUERY_FINAL" || { diff --git a/infra/scripts/index_scripts/create_sql_tables.py b/infra/scripts/index_scripts/create_sql_tables.py index adaa95a48..322023f71 100644 --- a/infra/scripts/index_scripts/create_sql_tables.py +++ b/infra/scripts/index_scripts/create_sql_tables.py @@ -2,7 +2,6 @@ managed_identity_client_id = 'mici_to-be-replaced' import pandas as pd -import pymssql import os from datetime import datetime diff --git a/infra/scripts/index_scripts/requirements.txt b/infra/scripts/index_scripts/requirements.txt index 57cd45ab9..5dc5b5fab 100644 --- a/infra/scripts/index_scripts/requirements.txt +++ b/infra/scripts/index_scripts/requirements.txt @@ -10,7 +10,6 @@ azure-ai-textanalytics azure-search-documents==11.6.0b9 azure-keyvault-secrets pandas -pymssql datetime pyodbc==5.2.0 \ No newline at end of file diff --git a/infra/scripts/run_create_index_scripts.sh b/infra/scripts/run_create_index_scripts.sh index c701d4700..0f7da6294 100644 --- a/infra/scripts/run_create_index_scripts.sh +++ b/infra/scripts/run_create_index_scripts.sh @@ -118,13 +118,23 @@ if [ -n "$managedIdentityClientId" ]; then sed -i "s/mici_to-be-replaced/${managedIdentityClientId}/g" ${pythonScriptPath}"create_sql_tables.py" fi +# Determine the correct Python command +if command -v python3 &> /dev/null; then + PYTHON_CMD="python3" +elif command -v python &> /dev/null; then + PYTHON_CMD="python" +else + echo "Python is not installed on this system. Or it is not added in the PATH." + exit 1 +fi + # create virtual environment # Check if the virtual environment already exists if [ -d $pythonScriptPath"scriptenv" ]; then echo "Virtual environment already exists. Skipping creation." else echo "Creating virtual environment" - python3 -m venv $pythonScriptPath"scriptenv" + $PYTHON_CMD -m venv $pythonScriptPath"scriptenv" fi # Activate the virtual environment