Skip to content

Commit 13aa4cc

Browse files
refactor: Replace Container App with Deployment Scripts for SQL and Post-Deployment Operations & update model capacity similar to bicep
2 parents e3c9d0a + e963341 commit 13aa4cc

12 files changed

+1032
-423
lines changed

.github/workflows/deploy-KMGeneric.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
- cron: '0 9,21 * * *' # Runs at 9:00 AM and 9:00 PM GMT
1313
workflow_dispatch: # Allow manual triggering
1414
env:
15-
GPT_MIN_CAPACITY: 250
16-
TEXT_EMBEDDING_MIN_CAPACITY: 90
15+
GPT_MIN_CAPACITY: 150
16+
TEXT_EMBEDDING_MIN_CAPACITY: 80
1717
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
1818
jobs:
1919
deploy:
@@ -40,8 +40,8 @@ jobs:
4040
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
4141
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
4242
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
43-
export GPT_MIN_CAPACITY="150"
44-
export TEXT_EMBEDDING_MIN_CAPACITY="80"
43+
export GPT_MIN_CAPACITY=${{ env.GPT_MIN_CAPACITY }}
44+
export TEXT_EMBEDDING_MIN_CAPACITY=${{ env.TEXT_EMBEDDING_MIN_CAPACITY }}
4545
export AZURE_REGIONS="${{ vars.AZURE_REGIONS_KM }}"
4646
chmod +x infra/scripts/checkquota_km.sh
4747
if ! infra/scripts/checkquota_km.sh; then

documents/QuotaCheck.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ azd auth login
1010

1111
### 📌 Default Models & Capacities:
1212
```
13-
gpt-4o:30, gpt-4o-mini:30, gpt-4:30, text-embedding-ada-002:80
13+
gpt-4o:150, gpt-4o-mini:150, gpt-4:150, text-embedding-ada-002:80
1414
```
1515
### 📌 Default Regions:
1616
```
@@ -36,19 +36,19 @@ eastus, uksouth, eastus2, northcentralus, swedencentral, westus, westus2, southc
3636
```
3737
✔️ Check specific model(s) in default regions:
3838
```
39-
./quota_check_params.sh --models gpt-4o:30,text-embedding-ada-002:80
39+
./quota_check_params.sh --models gpt-4o:150,text-embedding-ada-002:80
4040
```
4141
✔️ Check default models in specific region(s):
4242
```
4343
./quota_check_params.sh --regions eastus,westus
4444
```
4545
✔️ Passing Both models and regions:
4646
```
47-
./quota_check_params.sh --models gpt-4o:30 --regions eastus,westus2
47+
./quota_check_params.sh --models gpt-4o:150 --regions eastus,westus2
4848
```
4949
✔️ All parameters combined:
5050
```
51-
./quota_check_params.sh --models gpt-4:30,text-embedding-ada-002:80 --regions eastus,westus --verbose
51+
./quota_check_params.sh --models gpt-4:150,text-embedding-ada-002:80 --regions eastus,westus --verbose
5252
```
5353

5454
### **Sample Output**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
targetScope = 'resourceGroup'
2+
3+
@description('The Azure region for the resource.')
4+
param location string
5+
6+
@description('The tags to associate with this resource.')
7+
param tags object = {}
8+
9+
@description('The database roles to assign to the user.')
10+
param databaseRoles string[] = ['db_datareader']
11+
12+
@description('The name of the User Assigned Managed Identity to be used.')
13+
param managedIdentityName string
14+
15+
@description('The principal (or object) ID of the user to create.')
16+
param principalId string
17+
18+
@description('The name of the user to create.')
19+
param principalName string
20+
21+
@description('The name of the SQL Database resource.')
22+
param sqlDatabaseName string
23+
24+
@description('The name of the SQL Server resource.')
25+
param sqlServerName string
26+
27+
@description('Do not set - unique script ID to force the script to run.')
28+
param uniqueScriptId string = newGuid()
29+
30+
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
31+
name: managedIdentityName
32+
}
33+
34+
resource createSqlUserAndRole 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
35+
name: 'sqlUserRole-${guid(principalId, sqlServerName, sqlDatabaseName)}'
36+
location: location
37+
tags: tags
38+
kind: 'AzurePowerShell'
39+
identity: {
40+
type: 'UserAssigned'
41+
userAssignedIdentities: {
42+
'${managedIdentity.id}': {}
43+
}
44+
}
45+
properties: {
46+
forceUpdateTag: uniqueScriptId
47+
azPowerShellVersion: '7.2'
48+
retentionInterval: 'PT1H'
49+
cleanupPreference: 'OnSuccess'
50+
arguments: join(
51+
[
52+
'-SqlServerName \'${sqlServerName}\''
53+
'-SqlDatabaseName \'${sqlDatabaseName}\''
54+
'-ClientId \'${principalId}\''
55+
'-DisplayName \'${principalName}\''
56+
'-DatabaseRoles \'${join(databaseRoles, ',')}\''
57+
],
58+
' '
59+
)
60+
scriptContent: loadTextContent('./scripts/add_user_scripts/create-sql-user-and-role.ps1')
61+
}
62+
}

infra/deploy_index_scripts.bicep

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@description('Specifies the location for resources.')
2+
param solutionLocation string
3+
4+
param baseUrl string
5+
param keyVaultName string
6+
param managedIdentityResourceId string
7+
param managedIdentityClientId string
8+
9+
resource create_index 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
10+
kind:'AzureCLI'
11+
name: 'create_search_indexes'
12+
location: solutionLocation
13+
identity: {
14+
type: 'UserAssigned'
15+
userAssignedIdentities: {
16+
'${managedIdentityResourceId}' : {}
17+
}
18+
}
19+
properties: {
20+
azCliVersion: '2.52.0'
21+
primaryScriptUri: '${baseUrl}infra/scripts/run_create_index_scripts.sh'
22+
arguments: '${baseUrl} ${keyVaultName} ${managedIdentityClientId}'
23+
timeout: 'PT1H'
24+
retentionInterval: 'PT1H'
25+
cleanupPreference:'OnSuccess'
26+
}
27+
}

infra/deploy_post_deployment_scripts.bicep

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

infra/deploy_sql_db.bicep

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
param solutionLocation string
22
param keyVaultName string
3-
param managedIdentityObjectId string
43
param managedIdentityName string
5-
64
param serverName string
75
param sqlDBName string
6+
param sqlUsers array = []
7+
88
var location = solutionLocation
9-
var administratorLogin = 'sqladmin'
10-
var administratorLoginPassword = 'TestPassword_1234'
9+
10+
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
11+
name: managedIdentityName
12+
}
1113

1214
resource sqlServer 'Microsoft.Sql/servers@2023-08-01-preview' = {
1315
name: serverName
@@ -17,10 +19,10 @@ resource sqlServer 'Microsoft.Sql/servers@2023-08-01-preview' = {
1719
publicNetworkAccess: 'Enabled'
1820
version: '12.0'
1921
restrictOutboundNetworkAccess: 'Disabled'
20-
minimalTlsVersion: '1.2' // Enforce TLS 1.2 to comply with Azure policy
22+
minimalTlsVersion: '1.2'
2123
administrators: {
2224
login: managedIdentityName
23-
sid: managedIdentityObjectId
25+
sid: managedIdentity.properties.principalId
2426
tenantId: subscription().tenantId
2527
administratorType: 'ActiveDirectory'
2628
azureADOnlyAuthentication: true
@@ -66,6 +68,21 @@ resource sqlDB 'Microsoft.Sql/servers/databases@2023-08-01-preview' = {
6668
}
6769
}
6870

71+
module sqluser 'create-sql-user-and-role.bicep' = [
72+
for user in sqlUsers: {
73+
name: 'sqluser-${guid(solutionLocation, user.principalId, user.principalName, sqlDB.name, sqlServer.name)}'
74+
params: {
75+
managedIdentityName: managedIdentityName
76+
location: solutionLocation
77+
sqlDatabaseName: sqlDB.name
78+
sqlServerName: sqlServer.name
79+
principalId: user.principalId
80+
principalName: user.principalName
81+
databaseRoles: user.databaseRoles
82+
}
83+
}
84+
]
85+
6986
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
7087
name: keyVaultName
7188
}
@@ -86,22 +103,5 @@ resource sqldbDatabaseEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-previe
86103
}
87104
}
88105

89-
resource sqldbDatabaseUsername 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
90-
parent: keyVault
91-
name: 'SQLDB-USERNAME'
92-
properties: {
93-
value: administratorLogin
94-
}
95-
}
96-
97-
resource sqldbDatabasePwd 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
98-
parent: keyVault
99-
name: 'SQLDB-PASSWORD'
100-
properties: {
101-
value: administratorLoginPassword
102-
}
103-
}
104-
105106
output sqlServerName string = '${serverName}.database.windows.net'
106107
output sqlDbName string = sqlDBName
107-
output sqlDbUser string = administratorLogin
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@description('Specifies the location for resources.')
2+
param solutionLocation string
3+
param baseUrl string
4+
param managedIdentityResourceId string
5+
param managedIdentityClientId string
6+
param storageAccountName string
7+
param containerName string
8+
9+
resource copy_demo_Data 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
10+
kind:'AzureCLI'
11+
name: 'copy_demo_Data'
12+
location: solutionLocation
13+
identity:{
14+
type:'UserAssigned'
15+
userAssignedIdentities: {
16+
'${managedIdentityResourceId}' : {}
17+
}
18+
}
19+
properties: {
20+
azCliVersion: '2.52.0'
21+
primaryScriptUri: '${baseUrl}infra/scripts/copy_kb_files.sh'
22+
arguments: '${storageAccountName} ${containerName} ${baseUrl} ${managedIdentityClientId}'
23+
timeout: 'PT1H'
24+
retentionInterval: 'PT1H'
25+
cleanupPreference:'OnSuccess'
26+
}
27+
}

0 commit comments

Comments
 (0)