Skip to content

Commit e4cd089

Browse files
feat: Code changes related to migrating azure function to App (#507)
* Added required code changes to migrate azure function to app * added more changes for azure fn to app migration * bicep chanegs * Added more bicep changes to removed fn app related code * Added AI Foundry/Project SDK changes * pylint fix * pylint fix * pylint fix3 * updated test to use USE_INTERNAL_STREAM * updated test_app.py to resolve the unit testing issue * added ai developer role to web app, slicing response from sql function as per length, updated main.bicep references * Refactor: Remove deprecated Bicep modules and Azure Function code * Refactor: Remove unused Docker configuration for Azure Function * Refactor: Remove unused variables and environment settings from Bicep templates --------- Co-authored-by: Harsh-Microsoft <[email protected]>
1 parent b661adc commit e4cd089

29 files changed

+497
-1485
lines changed

.github/workflows/CAdeploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
set -e
115115
az deployment group create \
116116
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
117-
--template-file infra/bicep/main.bicep \
117+
--template-file infra/main.bicep \
118118
--parameters solutionPrefix=${{ env.SOLUTION_PREFIX }} cosmosLocation=${{ env.AZURE_LOCATION }}
119119
120120
- name: List KeyVaults and Store in Array

.github/workflows/build-clientadvisor.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ jobs:
2121
- app_name: byc-wa-app
2222
dockerfile: src/App/WebApp.Dockerfile
2323
password_secret: DOCKER_PASSWORD
24-
- app_name: byc-wa-fn
25-
dockerfile: src/AzureFunction/Dockerfile
26-
password_secret: DOCKER_PASSWORD
2724

2825
uses: ./.github/workflows/build-docker.yml
2926
with:

azure.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ metadata:
66
77
88

9-
infra:
10-
provider: bicep
11-
path: infra/bicep
12-
module: main
13-
149
hooks:
1510
postprovision:
1611
windows:

infra/deploy_ai_foundry.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
145145
apiProperties: {
146146
statisticsEnabled: false
147147
}
148+
publicNetworkAccess: 'Enabled'
148149
}
149150
}
150151

infra/deploy_ai_search_service.bicep

Lines changed: 0 additions & 43 deletions
This file was deleted.

infra/deploy_aihub_scripts.bicep

Lines changed: 0 additions & 29 deletions
This file was deleted.

infra/deploy_app_service.bicep

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ param AzureOpenAIEmbeddingEndpoint string = ''
120120
param WebAppEnableChatHistory string = 'False'
121121

122122
@description('Use Azure Function')
123-
param USE_AZUREFUNCTION string = 'True'
123+
param USE_INTERNAL_STREAM string = 'True'
124124

125125
@description('Azure Function Endpoint')
126126
param STREAMING_AZUREFUNCTION_ENDPOINT string = ''
@@ -163,6 +163,22 @@ param userassignedIdentityId string
163163
param userassignedIdentityClientId string
164164
param applicationInsightsId string
165165

166+
@secure()
167+
param azureSearchAdminKey string
168+
param azureSearchServiceEndpoint string
169+
170+
@description('Azure Function App SQL System Prompt')
171+
param sqlSystemPrompt string
172+
@description('Azure Function App CallTranscript System Prompt')
173+
param callTranscriptSystemPrompt string
174+
@description('Azure Function App Stream Text System Prompt')
175+
param streamTextSystemPrompt string
176+
177+
@secure()
178+
param aiProjectConnectionString string
179+
param useAIProjectClientFlag string = 'false'
180+
param aiProjectName string
181+
166182
// var WebAppImageName = 'DOCKER|byoaiacontainer.azurecr.io/byoaia-app:latest'
167183

168184
// var WebAppImageName = 'DOCKER|ncwaappcontainerreg1.azurecr.io/ncqaappimage:v1.0.0'
@@ -347,8 +363,8 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
347363
value: SQLDB_PASSWORD
348364
}
349365

350-
{name: 'USE_AZUREFUNCTION'
351-
value: USE_AZUREFUNCTION
366+
{name: 'USE_INTERNAL_STREAM'
367+
value: USE_INTERNAL_STREAM
352368
}
353369

354370
{name: 'STREAMING_AZUREFUNCTION_ENDPOINT'
@@ -386,6 +402,42 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = {
386402
name: 'SQLDB_USER_MID'
387403
value: userassignedIdentityClientId
388404
}
405+
{
406+
name: 'OPENAI_API_VERSION'
407+
value: AzureOpenAIApiVersion
408+
}
409+
{
410+
name: 'AZURE_AI_SEARCH_API_KEY'
411+
value: azureSearchAdminKey
412+
}
413+
{
414+
name: 'AZURE_AI_SEARCH_ENDPOINT'
415+
value: azureSearchServiceEndpoint
416+
}
417+
{
418+
name: 'SQLDB_CONNECTION_STRING'
419+
value: 'TBD'
420+
}
421+
{
422+
name: 'AZURE_SQL_SYSTEM_PROMPT'
423+
value: sqlSystemPrompt
424+
}
425+
{
426+
name: 'AZURE_CALL_TRANSCRIPT_SYSTEM_PROMPT'
427+
value: callTranscriptSystemPrompt
428+
}
429+
{
430+
name: 'AZURE_OPENAI_STREAM_TEXT_SYSTEM_PROMPT'
431+
value: streamTextSystemPrompt
432+
}
433+
{
434+
name: 'AZURE_AI_PROJECT_CONN_STRING'
435+
value: aiProjectConnectionString
436+
}
437+
{
438+
name: 'USE_AI_PROJECT_CLIENT'
439+
value: useAIProjectClientFlag
440+
}
389441
]
390442
linuxFxVersion: WebAppImageName
391443
}
@@ -422,4 +474,21 @@ module cosmosUserRole 'core/database/cosmos/cosmos-role-assign.bicep' = {
422474
]
423475
}
424476

477+
resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
478+
name: aiProjectName
479+
}
480+
481+
resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
482+
name: '64702f94-c441-49e6-a78b-ef80e0188fee'
483+
}
484+
485+
resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
486+
name: guid(Website.name, aiHubProject.id, aiDeveloper.id)
487+
scope: aiHubProject
488+
properties: {
489+
roleDefinitionId: aiDeveloper.id
490+
principalId: Website.identity.principalId
491+
}
492+
}
493+
425494
output webAppUrl string = 'https://${WebsiteName}.azurewebsites.net'

infra/deploy_azure_ai_service.bicep

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)