Skip to content

Commit ee63bd5

Browse files
committed
Combine last 9 commits
1 parent 10904b6 commit ee63bd5

File tree

7 files changed

+150
-17
lines changed

7 files changed

+150
-17
lines changed

.github/workflows/azure-dev.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
2727
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
2828
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
29+
AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }}
2930
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
3031
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
3132
# project specific
@@ -95,7 +96,7 @@ jobs:
9596
USE_SPEECH_OUTPUT_BROWSER: ${{ vars.USE_SPEECH_OUTPUT_BROWSER }}
9697
USE_SPEECH_OUTPUT_AZURE: ${{ vars.USE_SPEECH_OUTPUT_AZURE }}
9798
AZURE_SPEECH_SERVICE: ${{ vars.AZURE_SPEECH_SERVICE }}
98-
AZURE_SPEECH_SERVICE_RESOURCE_GROUP: ${{ vars.AZURE_SPEECH_RESOURCE_GROUP }}
99+
AZURE_SPEECH_SERVICE_RESOURCE_GROUP: ${{ vars.AZURE_SPEECH_SERVICE_RESOURCE_GROUP }}
99100
AZURE_SPEECH_SERVICE_LOCATION: ${{ vars.AZURE_SPEECH_SERVICE_LOCATION }}
100101
AZURE_SPEECH_SERVICE_SKU: ${{ vars.AZURE_SPEECH_SERVICE_SKU }}
101102
AZURE_SPEECH_SERVICE_VOICE: ${{ vars.AZURE_SPEECH_SERVICE_VOICE }}
@@ -116,6 +117,7 @@ jobs:
116117
USE_CHAT_HISTORY_BROWSER: ${{ vars.USE_CHAT_HISTORY_BROWSER }}
117118
USE_MEDIA_DESCRIBER_AZURE_CU: ${{ vars.USE_MEDIA_DESCRIBER_AZURE_CU }}
118119
USE_AI_PROJECT: ${{ vars.USE_AI_PROJECT }}
120+
SERVICE_WEB_RESOURCE_EXISTS: ${{ vars.SERVICE_WEB_RESOURCE_EXISTS }}
119121
steps:
120122
- name: Checkout
121123
uses: actions/checkout@v4
@@ -126,7 +128,7 @@ jobs:
126128
- name: Install Nodejs
127129
uses: actions/setup-node@v4
128130
with:
129-
node-version: 18
131+
node-version: 20
130132

131133
- name: Log in with Azure (Federated Credentials)
132134
if: ${{ env.AZURE_CLIENT_ID != '' }}
@@ -151,6 +153,25 @@ jobs:
151153
env:
152154
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
153155

156+
- name: Set default resource group variables
157+
run: |
158+
DEFAULT_RG="$AZURE_RESOURCE_GROUP"
159+
for var in \
160+
AZURE_OPENAI_RESOURCE_GROUP \
161+
AZURE_DOCUMENTINTELLIGENCE_RESOURCE_GROUP \
162+
AZURE_COMPUTER_VISION_RESOURCE_GROUP \
163+
AZURE_CONTENT_UNDERSTANDING_RESOURCE_GROUP \
164+
AZURE_SEARCH_SERVICE_RESOURCE_GROUP \
165+
AZURE_STORAGE_RESOURCE_GROUP \
166+
AZURE_SPEECH_SERVICE_RESOURCE_GROUP \
167+
AZURE_COSMOSDB_RESOURCE_GROUP; do
168+
if [ -z "${!var}" ]; then
169+
echo "Setting $var to default $DEFAULT_RG"
170+
echo "$var=$DEFAULT_RG" >> "$GITHUB_ENV"
171+
fi
172+
done
173+
shell: bash
174+
154175
- name: Provision Infrastructure
155176
run: azd provision --no-prompt
156177
env:

azure.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ services:
88
project: ./app/backend
99
language: py
1010
# Please check docs/azure_container_apps.md for more information on how to deploy to Azure Container Apps
11-
host: containerapp
11+
# host: containerapp
1212
docker:
1313
remoteBuild: true
1414
# Please check docs/azure_app_service.md for more information on how to deploy to Azure App Service
15-
# host: appservice
15+
host: appservice
1616
hooks:
1717
# This hook is called when App Service is the host
1818
prepackage:
@@ -122,11 +122,13 @@ pipeline:
122122
- AZURE_ADLS_GEN2_STORAGE_ACCOUNT
123123
- AZURE_ADLS_GEN2_FILESYSTEM_PATH
124124
- AZURE_ADLS_GEN2_FILESYSTEM
125+
- AZURE_RESOURCE_GROUP
125126
- DEPLOYMENT_TARGET
126127
- AZURE_CONTAINER_APPS_WORKLOAD_PROFILE
127128
- USE_CHAT_HISTORY_BROWSER
128129
- USE_MEDIA_DESCRIBER_AZURE_CU
129130
- USE_AI_PROJECT
131+
- SERVICE_WEB_RESOURCE_EXISTS
130132
secrets:
131133
- AZURE_SERVER_APP_SECRET
132134
- AZURE_CLIENT_APP_SECRET

configure_demo.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
# configure_demo.sh – prepares azd environment for the public demo using existing resource group & storage account
3+
set -euo pipefail
4+
5+
# ----- parameters you may tweak -----
6+
RG="rg-jacob-paul-rag" # existing resource group
7+
SUB="6c8e23df-4aec-4ed5-bec5-79853ea6c6c6" # subscription id
8+
LOC="eastus2" # default location
9+
ENV_NAME="demo" # azd env folder name
10+
STORAGE_ACCT="stinternalrag001" # existing ADLS Gen2 account
11+
12+
# fixed resource names following pattern <abbr>-internal-3c-rag
13+
SEARCH="srch-internal-3c-rag"
14+
OPENAI="oai-internal-3c-rag"
15+
DOCINT="di-internal-3c-rag"
16+
SPEECH="spch-internal-3c-rag"
17+
PLAN="asp-internal-3c-rag"
18+
WEBAPP="app-internal-3c-rag"
19+
COSMOS="cosmosinternal3crag" # Cosmos account names cannot have hyphens
20+
21+
# ----- create / switch azd env -----
22+
# create or switch to environment
23+
if azd env list --output json | grep -q "\"$ENV_NAME\""; then
24+
echo "Selecting existing environment $ENV_NAME"
25+
azd env select "$ENV_NAME"
26+
else
27+
azd env new "$ENV_NAME" --subscription "$SUB" --location "$LOC"
28+
fi
29+
# pin to existing resource group
30+
azd env set AZURE_RESOURCE_GROUP "$RG"
31+
32+
# ----- hosting SKUs / flags -----
33+
azd env set DEPLOYMENT_TARGET appservice
34+
azd env set AZURE_APP_SERVICE_SKU P0v3
35+
azd env set AZURE_SEARCH_SERVICE_SKU standard
36+
azd env set SERVICE_WEB_RESOURCE_EXISTS true
37+
38+
# ----- explicit resource names -----
39+
azd env set AZURE_STORAGE_ACCOUNT "$STORAGE_ACCT"
40+
azd env set AZURE_STORAGE_CONTAINER "content"
41+
azd env set AZURE_STORAGE_RESOURCE_GROUP "$RG"
42+
azd env set AZURE_APPLICATION_INSIGHTS "appi-internal-3c-rag"
43+
azd env set AZURE_APPLICATION_INSIGHTS_DASHBOARD "dash-internal-3c-rag"
44+
azd env set AZURE_LOG_ANALYTICS "log-internal-3c-rag"
45+
azd env set AZURE_SEARCH_SERVICE "$SEARCH"
46+
azd env set AZURE_OPENAI_SERVICE "$OPENAI"
47+
azd env set AZURE_DOCUMENTINTELLIGENCE_SERVICE "$DOCINT"
48+
azd env set AZURE_SPEECH_SERVICE "$SPEECH"
49+
azd env set AZURE_APP_SERVICE_PLAN "$PLAN"
50+
azd env set AZURE_APP_SERVICE "$WEBAPP"
51+
azd env set AZURE_COSMOSDB_ACCOUNT "$COSMOS"
52+
53+
# ----- model / vision -----
54+
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-large
55+
azd env set AZURE_OPENAI_EMB_DIMENSIONS 3072
56+
# Enable GPT-4 Vision feature flag expected by template
57+
azd env set USE_GPT4V true
58+
# Optional: set the GPT-4V deployment/model names (can be blank to let template default)
59+
azd env set AZURE_OPENAI_GPT4V_MODEL gpt-4o
60+
azd env set AZURE_OPENAI_GPT4V_DEPLOYMENT gpt4v
61+
azd env set USE_MEDIA_DESCRIBER_AZURE_CU false
62+
63+
# ----- retrieval options -----
64+
azd env set AZURE_SEARCH_SEMANTIC_RANKER standard
65+
azd env set AZURE_SEARCH_QUERY_REWRITING true
66+
67+
# ----- chat history -----
68+
azd env set USE_CHAT_HISTORY_COSMOS true
69+
70+
# ----- speech -----
71+
azd env set USE_SPEECH_INPUT_BROWSER true
72+
azd env set USE_SPEECH_OUTPUT_AZURE true
73+
azd env set AZURE_SPEECH_SERVICE_VOICE en-US-AndrewMultilingualNeural
74+
75+
# ----- security & uploads -----
76+
azd env set AZURE_USE_AUTHENTICATION true
77+
TENANT_ID=$(az account show --query tenantId -o tsv 2>/dev/null || echo "")
78+
if [ -n "$TENANT_ID" ]; then
79+
azd env set AZURE_AUTH_TENANT_ID "$TENANT_ID"
80+
azd env set AZURE_TENANT_ID "$TENANT_ID"
81+
fi
82+
azd env set USE_USER_UPLOAD true
83+
84+
# content understanding (Azure AI Foundry account)
85+
azd env set AZURE_COMPUTER_VISION_SERVICE "cu-internal-3c-rag"
86+
87+
# user-upload storage account (ADLS Gen2)
88+
azd env set AZURE_ADLS_GEN2_STORAGE_ACCOUNT "userstinternal3crag"
89+
azd env set AZURE_ADLS_GEN2_FILESYSTEM "user-content"
90+
azd env set AZURE_ADLS_GEN2_FILESYSTEM_PATH ""
91+
92+
# ----- regional parameters to avoid interactive prompts -----
93+
# keep required uppercase vars
94+
azd env set AZURE_OPENAI_LOCATION "$LOC"
95+
azd env set AZURE_DOCUMENTINTELLIGENCE_LOCATION "eastus"
96+
97+
echo "✔ Demo environment configured. Run 'azd up' next."

infra/core/host/appservice.bicep

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,25 @@ var appServiceProperties = {
8383
publicNetworkAccess: publicNetworkAccess
8484
}
8585

86-
resource appService 'Microsoft.Web/sites@2022-03-01' = {
86+
// add flag to indicate the App Service already exists and should not be re-created
87+
@description('If true the module will reference an existing App Service instead of creating a new one.')
88+
param exists bool = false
89+
90+
// Reference existing site when `exists` is true
91+
resource appServiceExisting 'Microsoft.Web/sites@2022-03-01' existing = if (exists) {
92+
name: name
93+
}
94+
95+
// Create or update site only when it doesn't already exist
96+
resource appService 'Microsoft.Web/sites@2022-03-01' = if (!exists) {
8797
name: name
8898
location: location
8999
tags: tags
90100
kind: kind
91101
properties: appServiceProperties
92102
identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }
93103

94-
resource configAppSettings 'config' = {
104+
resource configAppSettings 'config' = if (!exists) {
95105
name: 'appsettings'
96106
properties: union(appSettings,
97107
{
@@ -103,7 +113,7 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
103113
!empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
104114
}
105115

106-
resource configLogs 'config' = {
116+
resource configLogs 'config' = if (!exists) {
107117
name: 'logs'
108118
properties: {
109119
applicationLogs: { fileSystem: { level: 'Verbose' } }
@@ -116,21 +126,21 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
116126
]
117127
}
118128

119-
resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = {
129+
resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = if (!exists) {
120130
name: 'ftp'
121131
properties: {
122132
allow: false
123133
}
124134
}
125135

126-
resource basicPublishingCredentialsPoliciesScm 'basicPublishingCredentialsPolicies' = {
136+
resource basicPublishingCredentialsPoliciesScm 'basicPublishingCredentialsPolicies' = if (!exists) {
127137
name: 'scm'
128138
properties: {
129139
allow: false
130140
}
131141
}
132142

133-
resource configAuth 'config' = if (!(empty(clientAppId)) && !disableAppServicesAuthentication) {
143+
resource configAuth 'config' = if (!exists && !(empty(clientAppId)) && !disableAppServicesAuthentication) {
134144
name: 'authsettingsV2'
135145
properties: {
136146
globalValidation: {
@@ -174,7 +184,10 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing
174184
name: applicationInsightsName
175185
}
176186

177-
output id string = appService.id
178-
output identityPrincipalId string = managedIdentity ? appService.identity.principalId : ''
179-
output name string = appService.name
180-
output uri string = 'https://${appService.properties.defaultHostName}'
187+
// Choose correct reference for outputs
188+
var appRef = exists ? appServiceExisting : appService
189+
190+
output id string = resourceId('Microsoft.Web/sites', name)
191+
output identityPrincipalId string = managedIdentity ? appRef.identity.principalId : ''
192+
output name string = name
193+
output uri string = 'https://${appRef.properties.defaultHostName}'

infra/core/security/documentdb-sql-role.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2023-04-15' exis
1414
name: databaseAccountName
1515
}
1616

17-
resource sqlRoleAssignment 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2023-04-15' = {
17+
resource sqlRoleAssignment 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2023-04-15' = if (!empty(principalId)) {
1818
name: guid(databaseAccount.id, principalId, roleDefinitionId)
1919
parent: databaseAccount
2020
properties: {

infra/core/security/role.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ param principalId string
1111
param principalType string = 'ServicePrincipal'
1212
param roleDefinitionId string
1313

14-
resource role 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
14+
resource role 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!empty(principalId)) {
1515
name: guid(subscription().id, resourceGroup().id, principalId, roleDefinitionId)
1616
properties: {
1717
principalId: principalId

infra/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ module backend 'core/host/appservice.bicep' = if (deploymentTarget == 'appservic
481481
name: !empty(backendServiceName) ? backendServiceName : '${abbrs.webSitesAppService}backend-${resourceToken}'
482482
location: location
483483
tags: union(tags, { 'azd-service-name': 'backend' })
484-
// Need to check deploymentTarget again due to https://github.com/Azure/bicep/issues/3990
485484
appServicePlanId: deploymentTarget == 'appservice' ? appServicePlan.outputs.id : ''
486485
runtimeName: 'python'
487486
runtimeVersion: '3.11'
@@ -499,6 +498,7 @@ module backend 'core/host/appservice.bicep' = if (deploymentTarget == 'appservic
499498
authenticationIssuerUri: authenticationIssuerUri
500499
use32BitWorkerProcess: appServiceSkuName == 'F1'
501500
alwaysOn: appServiceSkuName != 'F1'
501+
exists: webAppExists
502502
appSettings: union(appEnvVariables, {
503503
AZURE_SERVER_APP_SECRET: serverAppSecret
504504
AZURE_CLIENT_APP_SECRET: clientAppSecret

0 commit comments

Comments
 (0)