Skip to content

Commit 3c3e4d9

Browse files
Roopan-MicrosoftAjitPadhi-MicrosoftPavan-Microsoftross-p-smithgpickett
authored
fix: WAF aligned changes merge from dev to main (#1894)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Ajit Padhi <[email protected]> Co-authored-by: Pavan-Microsoft <[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]>
1 parent d6c3dad commit 3c3e4d9

File tree

118 files changed

+66528
-13434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+66528
-13434
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/devcontainers/python:3.11
1+
FROM mcr.microsoft.com/devcontainers/python:3.11-bookworm
22

33
# install git
44
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

.github/workflows/build-docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
context: .
6363
file: ${{ inputs.dockerfile }}
6464
push: ${{ inputs.push }}
65-
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 }}
65+
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 }}
6666
tags: |
67-
${{ 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' }}
68-
${{ inputs.new_registry }}/${{ inputs.app_name }}:${{ steps.date.outputs.date }}_${{ github.run_number }}
67+
${{ 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' }}
68+
${{ 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 }}

.github/workflows/ci.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636
- name: Checkout code
3737
uses: actions/checkout@v4
3838

39+
- name: Install AZD
40+
run: |
41+
set -e
42+
echo "Fetching deployment output..."
43+
# Install azd (Azure Developer CLI) - required by process_sample_data.sh
44+
curl -fsSL https://aka.ms/install-azd.sh | bash
45+
3946
- name: Run Quota Check
4047
id: quota-check
4148
run: |
@@ -79,6 +86,45 @@ jobs:
7986
echo "Selected Region: $VALID_REGION"
8087
echo "AZURE_LOCATION=$VALID_REGION" >> $GITHUB_ENV
8188
89+
- name: Generate Resource Group Name
90+
id: generate_rg_name
91+
run: |
92+
echo "Generating a unique resource group name..."
93+
ACCL_NAME="cwyd" # Account name as specified
94+
SHORT_UUID=$(uuidgen | cut -d'-' -f1)
95+
UNIQUE_RG_NAME="arg-${ACCL_NAME}-${SHORT_UUID}"
96+
echo "RESOURCE_GROUP_NAME=${UNIQUE_RG_NAME}" >> $GITHUB_ENV
97+
echo "Generated RESOURCE_GROUP_NAME: ${UNIQUE_RG_NAME}"
98+
99+
- name: Check and Create Resource Group
100+
id: check_create_rg
101+
run: |
102+
echo "RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}"
103+
set -e
104+
echo "Checking if resource group exists..."
105+
rg_exists=$(az group exists --name ${{ env.RESOURCE_GROUP_NAME }})
106+
if [ "$rg_exists" = "false" ]; then
107+
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; }
109+
else
110+
echo "Resource group already exists."
111+
fi
112+
# Set output for other jobs
113+
echo "RESOURCE_GROUP_NAME=${{ env.RESOURCE_GROUP_NAME }}" >> $GITHUB_OUTPUT
114+
115+
116+
- name: Generate Unique Solution Prefix
117+
id: generate_solution_prefix
118+
run: |
119+
set -e
120+
COMMON_PART="pslc"
121+
TIMESTAMP=$(date +%s)
122+
UPDATED_TIMESTAMP=$(echo $TIMESTAMP | tail -c 3)
123+
UNIQUE_SOLUTION_SUFFIX="${COMMON_PART}${UPDATED_TIMESTAMP}"
124+
echo "SOLUTION_SUFFIX=${UNIQUE_SOLUTION_SUFFIX}" >> $GITHUB_ENV
125+
echo "SOLUTION_SUFFIX=${UNIQUE_SOLUTION_SUFFIX}" >> $GITHUB_OUTPUT
126+
echo "Generated SOLUTION_SUFFIX: ${UNIQUE_SOLUTION_SUFFIX}"
127+
82128
- name: Login to GitHub Container Registry
83129
uses: docker/login-action@v3
84130
with:
@@ -90,11 +136,11 @@ jobs:
90136
id: set-image-tag
91137
run: |
92138
if [[ "${{ github.event_name }}" == "schedule" ]]; then
93-
echo "imageTag=latest" >> $GITHUB_ENV
94-
echo "::set-output name=imageTag::latest"
139+
echo "imageTag=latest_waf" >> $GITHUB_ENV
140+
echo "::set-output name=imageTag::latest_waf"
95141
elif [[ "${{ github.ref_name }}" == "main" ]]; then
96-
echo "imageTag=latest" >> $GITHUB_ENV
97-
echo "::set-output name=imageTag::latest"
142+
echo "imageTag=latest_waf" >> $GITHUB_ENV
143+
echo "::set-output name=imageTag::latest_waf"
98144
else
99145
echo "imageTag=${{ github.ref_name }}" >> $GITHUB_ENV
100146
echo "::set-output name=imageTag::${{ github.ref_name }}"
@@ -103,8 +149,9 @@ jobs:
103149
- name: Pre-build image and deploy
104150
uses: devcontainers/[email protected]
105151
env:
106-
AZURE_ENV_NAME: ${{ github.run_id }}
152+
AZURE_ENV_NAME: ${{ env.SOLUTION_SUFFIX }}
107153
AZURE_LOCATION: ${{ env.AZURE_LOCATION }}
154+
AZURE_RESOURCE_GROUP: ${{ env.RESOURCE_GROUP_NAME }}
108155
with:
109156
push: never
110157
imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator
@@ -141,6 +188,7 @@ jobs:
141188
AZURE_SUBSCRIPTION_ID
142189
AZURE_ENV_NAME
143190
AZURE_LOCATION
191+
AZURE_RESOURCE_GROUP
144192
AUTH_ENABLED=false
145193
AZURE_USE_AUTHENTICATION=false
146194
AZURE_ENABLE_AUTH=false

.github/workflows/group_dependabot_security_updates.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ jobs:
6565
git config --global user.email "[email protected]"
6666
6767
- name: Install required tools
68-
uses: awalsh128/[email protected]
69-
with:
70-
packages: "jq gh"
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y jq gh
71+
shell: bash
7172

7273
- name: Enable strict error handling
7374
shell: bash

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ azd-login: ## 🔑 Login to Azure with azd and a SPN
6565
# Fixed Makefile section for deploy target
6666
deploy: azd-login ## Deploy everything to Azure
6767
@echo -e "\e[34m$@\e[0m" || true
68-
@azd env new ${AZURE_ENV_NAME}
68+
@echo "AZURE_ENV_NAME: '${AZURE_ENV_NAME}'"
69+
@echo "AZURE_LOCATION: '${AZURE_LOCATION}'"
70+
@echo "AZURE_RESOURCE_GROUP: '${AZURE_RESOURCE_GROUP}'"
71+
72+
# Validate required variables
73+
@if [ -z "${AZURE_ENV_NAME}" ]; then echo "❌ AZURE_ENV_NAME not set"; exit 1; fi
74+
@if [ -z "${AZURE_LOCATION}" ]; then echo "❌ AZURE_LOCATION not set"; exit 1; fi
75+
@if [ -z "${AZURE_RESOURCE_GROUP}" ]; then echo "❌ AZURE_RESOURCE_GROUP not set"; exit 1; fi
76+
77+
@azd env new ${AZURE_ENV_NAME} --location ${AZURE_LOCATION}
78+
@azd env set AZURE_RESOURCE_GROUP ${AZURE_RESOURCE_GROUP}
6979

7080
# Provision and deploy
7181
@azd provision --no-prompt

azure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name: chat-with-your-data-solution-accelerator
44
metadata:
5-
5+
66
hooks:
77
postprovision:
88
# run: ./infra/prompt-flow/create-prompt-flow.sh

code/backend/batch/local.settings.json.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"IsEncrypted": false,
33
"Values": {
44
"FUNCTIONS_WORKER_RUNTIME": "python",
5-
"AzureWebJobsStorage": "",
5+
"AzureWebJobsStorage__accountName": "",
66
"MyBindingConnection": "",
77
"AzureWebJobs.HttpExample.Disabled": "true"
88
},
@@ -11,4 +11,4 @@
1111
"CORS": "*",
1212
"CORSCredentials": false
1313
}
14-
}
14+
}

code/backend/batch/utilities/chat_history/database_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_conversation_client():
2525
f"https://{env_helper.AZURE_COSMOSDB_ACCOUNT}.documents.azure.com:443/"
2626
)
2727
credential = (
28-
get_azure_credential()
28+
get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID)
2929
if not env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
3030
else env_helper.AZURE_COSMOSDB_ACCOUNT_KEY
3131
)

code/backend/batch/utilities/chat_history/postgresdbservice.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import asyncpg
33
from datetime import datetime, timezone
44
from ..helpers.azure_credential_utils import get_azure_credential
5+
from ..helpers.env_helper import EnvHelper
56

67
from .database_client_base import DatabaseClientBase
78

@@ -13,6 +14,7 @@ class PostgresConversationClient(DatabaseClientBase):
1314
def __init__(
1415
self, user: str, host: str, database: str, enable_message_feedback: bool = False
1516
):
17+
self.env_helper = EnvHelper()
1618
self.user = user
1719
self.host = host
1820
self.database = database
@@ -21,7 +23,7 @@ def __init__(
2123

2224
async def connect(self):
2325
try:
24-
credential = get_azure_credential()
26+
credential = get_azure_credential(self.env_helper.MANAGED_IDENTITY_CLIENT_ID)
2527
token = credential.get_token(
2628
"https://ossrdbms-aad.database.windows.net/.default"
2729
).token
@@ -31,7 +33,7 @@ async def connect(self):
3133
database=self.database,
3234
password=token,
3335
port=5432,
34-
ssl="require",
36+
ssl=True,
3537
)
3638
except Exception as e:
3739
logger.error("Failed to connect to PostgreSQL: %s", e)

code/backend/batch/utilities/helpers/azure_blob_storage_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_queue_client():
2525
return QueueClient(
2626
account_url=f"https://{env_helper.AZURE_BLOB_ACCOUNT_NAME}.queue.core.windows.net/",
2727
queue_name=env_helper.DOCUMENT_PROCESSING_QUEUE_NAME,
28-
credential=get_azure_credential(),
28+
credential=get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID),
2929
message_encode_policy=BinaryBase64EncodePolicy(),
3030
)
3131

@@ -56,7 +56,7 @@ def __init__(
5656
if self.auth_type == "rbac":
5757
self.account_key = None
5858
self.blob_service_client = BlobServiceClient(
59-
account_url=self.endpoint, credential=get_azure_credential()
59+
account_url=self.endpoint, credential=get_azure_credential(env_helper.MANAGED_IDENTITY_CLIENT_ID)
6060
)
6161
self.user_delegation_key = self.request_user_delegation_key(
6262
blob_service_client=self.blob_service_client

0 commit comments

Comments
 (0)