Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 6364389

Browse files
ManagedAPP
1 parent 964b536 commit 6364389

File tree

9 files changed

+2041
-106
lines changed

9 files changed

+2041
-106
lines changed

infra/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ In the Azure Portal, go to Marketplace and create a `Service Catalog Managed App
3939
### 6. Deploy the managed app
4040

4141
In the Azure Portal, find and click on the managed app definition resource that was created in the previous step. A button option to `Deploy from definition` will be available. Click on it and proceed through the setup steps (defined by the `createUiDefinitions.json` file) that a consumer would experience when installing the managed app.
42+
43+
44+
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fgraphrag-accelerator%2Fblob%2Fharjit-managed-app%2Finfra%2FmainTemplate.json)
45+

infra/core/aks/aks.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ resource aks 'Microsoft.ContainerService/managedClusters@2024-09-02-preview' = {
6565
}
6666
properties: {
6767
enableRBAC: true
68-
disableLocalAccounts: true
68+
disableLocalAccounts: false
6969
dnsPrefix: !empty(dnsPrefix) ? dnsPrefix : toLower(clusterName)
7070
aadProfile: {
7171
managed: true

infra/core/aoai/aoai.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ param embeddingModelName string = 'text-embedding-ada-002'
1717
param embeddingModelVersion string
1818

1919
@description('TPM quota for llm model deployment (x1000)')
20-
param llmTpmQuota int = 10
20+
param llmTpmQuota int = 1
2121

2222
@description('TPM quota for embedding model deployment (x1000)')
23-
param embeddingTpmQuota int = 10
23+
param embeddingTpmQuota int = 1
2424

2525
resource aoai 'Microsoft.CognitiveServices/accounts@2024-10-01' = {
2626
name: openAiName

infra/core/apim/apim.graphrag-servicedef.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ param backendUrl string
55
param name string
66
param apimname string
77

8+
9+
10+
811
resource api 'Microsoft.ApiManagement/service/apis@2023-09-01-preview' = {
912
name: '${apimname}/${name}'
1013
properties: {

infra/core/scripts/deployment-script.bicep

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ param azure_apim_name string
1616
param managed_identity_aks string
1717
param ai_search_name string
1818

19-
@description('Specifies the primary script URI.')
20-
param primaryScriptUri string
2119
param imagename string
2220
param imageversion string
21+
param script_file string
2322

2423

2524
param azure_aoai_endpoint string
@@ -47,6 +46,8 @@ param azure_workload_identity_client_id string
4746
param azure_workload_identity_principal_id string
4847
param azure_workload_identity_name string
4948
param cognitive_services_audience string = 'https://cognitiveservices.azure.com/default'
49+
param public_storage_account_name string
50+
param public_storage_account_key string
5051

5152
var clusterAdminRoleDefinitionId = resourceId('Microsoft.Authorization/roleDefinitions', '0ab0b1a8-8aac-4efd-b8c2-3ee1fb270be8')
5253

@@ -55,13 +56,18 @@ resource aksCluster 'Microsoft.ContainerService/managedClusters@2022-11-02-previ
5556
name: azure_aks_name
5657
}
5758

59+
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
60+
name: uniqueString(resourceGroup().id)
61+
location: location
62+
}
63+
5864

5965
resource clusterAdminContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
6066
name: guid(managed_identity_aks, aksCluster.id, clusterAdminRoleDefinitionId)
6167
scope: aksCluster
6268
properties: {
6369
roleDefinitionId: clusterAdminRoleDefinitionId
64-
principalId: managed_identity_aks
70+
principalId: managedIdentity.properties.principalId
6571
principalType: 'ServicePrincipal'
6672
}
6773
}
@@ -73,10 +79,14 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01'= {
7379
identity: {
7480
type: 'UserAssigned'
7581
userAssignedIdentities: {
76-
'${managed_identity_aks}': {}
82+
'${managedIdentity.id}': {}
7783
}
7884
}
7985
properties: {
86+
storageAccountSettings: {
87+
storageAccountName: public_storage_account_name
88+
storageAccountKey: public_storage_account_key
89+
}
8090
forceUpdateTag: utcValue
8191
azCliVersion: '2.7.0'
8292
timeout: 'PT1H'
@@ -219,12 +229,19 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01'= {
219229

220230
value: azure_aoai_endpoint
221231
}
232+
233+
{
234+
name: 'AZURE_RESOURCE_GROUP'
235+
236+
value: resourceGroup().name
237+
}
222238

223239

224240
]
225241
cleanupPreference: 'OnSuccess'
226242
retentionInterval: 'P1D'
227-
primaryScriptUri: primaryScriptUri
243+
//primaryScriptUri: primaryScriptUri
244+
scriptContent:script_file
228245
}
229246
dependsOn: [
230247
aksCluster

infra/main.bicep

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,19 @@ param llmModelName string = 'gpt-4o'
6767
param llmModelVersion string = '2024-08-06'
6868
@description('Quota of the AOAI LLM model to use.')
6969
@minValue(1)
70-
param llmModelQuota int = 10
70+
param llmModelQuota int = 1
7171

7272
@description('Name of the AOAI embedding model to use. Must match official model id. For more information: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models')
7373
@allowed(['text-embedding-ada-002', 'text-embedding-3-large'])
7474
param embeddingModelName string = 'text-embedding-ada-002'
7575
param embeddingModelVersion string = '2'
7676
@description('Quota of the AOAI embedding model to use.')
7777
@minValue(1)
78-
param embeddingModelQuota int = 10
78+
param embeddingModelQuota int = 1
79+
80+
81+
param publicStorageAccountName string =''
82+
param publicStorageAccountKey string =''
7983

8084
var abbrs = loadJsonContent('abbreviations.json')
8185
var tags = { 'azd-env-name': resourceGroup }
@@ -372,7 +376,7 @@ module deploymentScript 'core/scripts/deployment-script.bicep' ={
372376
utcValue: utcString
373377
name:'graphragscript'
374378
location:location
375-
subscriptionId:subscription().subscriptionId
379+
subscriptionId:subscription().id
376380
tenantid:tenant().tenantId
377381
acrserver:'graphrag.azure.acr.io'
378382
azure_location:location
@@ -387,7 +391,7 @@ module deploymentScript 'core/scripts/deployment-script.bicep' ={
387391
azure_apim_gateway_url:apim.outputs.apimGatewayUrl
388392
azure_apim_name :apim.outputs.name
389393
managed_identity_aks:aks.outputs.systemIdentity
390-
primaryScriptUri:'file://./scripts/deployment-script.sh'
394+
script_file:loadTextContent('managed-app/artifacts/scripts/updategraphrag.sh')
391395
ai_search_name:aiSearch.name
392396
azure_aoai_endpoint:aoai.outputs.openAiEndpoint
393397
azure_aoai_llm_model : aoai.outputs.llmModel
@@ -396,26 +400,30 @@ module deploymentScript 'core/scripts/deployment-script.bicep' ={
396400
azure_aoai_embedding_model:aoai.outputs.textEmbeddingModel
397401
azure_aoai_embedding_model_deployment_name:aoai.outputs.textEmbeddingModelDeploymentName
398402
azure_aoai_embedding_model_api_version:aoai.outputs.textEmbeddingModelApiVersion
399-
400403
azure_app_hostname:appHostname
401404
azure_app_url:appUrl
402405
azure_app_insights_connection_string:appInsights.outputs.connectionString
403-
404406
azure_cosmosdb_endpoint :cosmosdb.outputs.endpoint
405407
azure_cosmosdb_name:cosmosdb.outputs.name
406408
azure_cosmosdb_id:cosmosdb.outputs.id
407-
408409
azure_dns_zone_name:privateDnsZone.outputs.name
409-
410-
411410
azure_storage_account:storage.outputs.name
412411
azure_storage_account_blob_url:storage.outputs.primaryEndpoints.blob
413-
414412
azure_workload_identity_client_id:workloadIdentity.outputs.clientId
415413
azure_workload_identity_principal_id:workloadIdentity.outputs.principalId
416414
azure_workload_identity_name:workloadIdentity.outputs.name
417-
415+
public_storage_account_name: publicStorageAccountName
416+
public_storage_account_key: publicStorageAccountKey
417+
418+
}
419+
}
418420

421+
module apimgraphragservicedef 'core/apim/apim.graphrag-servicedef.bicep'={
422+
name: 'graphragservicedef-deployment'
423+
params:{
424+
name:'GraphRag'
425+
apimname:apim.outputs.name
426+
backendUrl:appUrl
419427
}
420428
}
421429

infra/managed-app/artifacts/scripts/updategraphrag.sh

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22
# Install kubectl
3+
set -e
34
az aks install-cli --only-show-errors
45

6+
az login --identity
7+
58
# Get AKS credentials
69
az aks get-credentials \
710
--admin \
8-
--name $clusterName \
9-
--resource-group $resourceGroupName \
10-
--subscription $subscriptionId \
11-
--only-show-errors
11+
--name $AZURE_AKS_NAME \
12+
--resource-group $AZURE_RESOURCE_GROUP --only-show-errors
1213

1314
# Check if the cluster is private or not
1415

@@ -27,37 +28,27 @@ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
2728
# Update Helm repos
2829
helm repo update
2930

30-
helm pull oci://graphrag.azurecr.io/graphrag --generate-name
31-
32-
tar -xvf graphrag-0.1.0.tgz
33-
31+
helm pull oci://graphrag.azurecr.io/graphrag --untar
3432

35-
36-
# Log whether the cluster is public or private
37-
echo "$clusterName AKS cluster is public"
38-
39-
# Install Prometheus
4033

41-
42-
# Install NGINX ingress controller using the internal load balancer
43-
helm upgrade -i graphrag ./graphrag -f ./graphrag/values.yaml \
44-
--namespace $aksNamespace --create-namespace \
45-
--set "serviceAccount.name=$AZURE_AKS_SERVICE_ACCOUNT_NAME" \
46-
--set "serviceAccount.annotations.azure\.workload\.identity/client-id=$AZURE_WORKLOAD_IDENTITY_CLIENT_ID" \
47-
--set "master.image.repository=graphrag.azurecr.io/$IMAGE_NAME" \
48-
--set "master.image.tag=$IMAGE_VERSION" \
49-
--set "ingress.host=$AZURE_APP_HOSTNAME" \
50-
--set "graphragConfig.APP_INSIGHTS_CONNECTION_STRING=$APP_INSIGHTS_CONNECTION_STRING" \
51-
--set "graphragConfig.AI_SEARCH_URL=https://$AI_SEARCH_NAME.search.windows.net" \
52-
--set "graphragConfig.COSMOS_URI_ENDPOINT=$AZURE_COSMOSDB_ENDPOINT" \
53-
--set "graphragConfig.GRAPHRAG_API_BASE=$AZURE_OPENAI_ENDPOINT" \
54-
--set "graphragConfig.GRAPHRAG_API_VERSION=$AZURE_AOAI_LLM_MODEL_API_VERSION" \
55-
--set "graphragConfig.GRAPHRAG_LLM_MODEL=$AZURE_AOAI_LLM_MODEL"\
56-
--set "graphragConfig.GRAPHRAG_LLM_DEPLOYMENT_NAME=$AZURE_AOAI_LLM_MODEL_DEPLOYMENT_NAME" \
57-
--set "graphragConfig.GRAPHRAG_EMBEDDING_MODEL=$AZURE_AOAI_EMBEDDING_MODEL" \
58-
--set "graphragConfig.GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME=$AZURE_AOAI_EMBEDDING_MODEL_DEPLOYMENT_NAME" \
59-
--set "graphragConfig.COGNITIVE_SERVICES_AUDIENCE=$COGNITIVE_SERVICES_AUDIENCE" \
60-
--set "graphragConfig.STORAGE_ACCOUNT_BLOB_URL=$AZURE_STORAGE_ACCOUNT_BLOB_URL"
34+
helm upgrade -i graphrag ./graphrag -f ./graphrag/values.yaml \
35+
--namespace $aksNamespace --create-namespace \
36+
--set "serviceAccount.name=$AZURE_AKS_SERVICE_ACCOUNT_NAME" \
37+
--set "serviceAccount.annotations.azure\.workload\.identity/client-id=$AZURE_WORKLOAD_IDENTITY_CLIENT_ID" \
38+
--set "master.image.repository=graphrag.azurecr.io/$IMAGE_NAME" \
39+
--set "master.image.tag=$IMAGE_VERSION" \
40+
--set "ingress.host=$AZURE_APP_HOSTNAME" \
41+
--set "graphragConfig.APPLICATIONINSIGHTS_CONNECTION_STRING=$APP_INSIGHTS_CONNECTION_STRING" \
42+
--set "graphragConfig.AI_SEARCH_URL=https://$AI_SEARCH_NAME.search.windows.net" \
43+
--set "graphragConfig.COSMOS_URI_ENDPOINT=$AZURE_COSMOSDB_ENDPOINT" \
44+
--set "graphragConfig.GRAPHRAG_API_BASE=$AZURE_OPENAI_ENDPOINT" \
45+
--set "graphragConfig.GRAPHRAG_API_VERSION=$AZURE_AOAI_LLM_MODEL_API_VERSION" \
46+
--set "graphragConfig.GRAPHRAG_LLM_MODEL=$AZURE_AOAI_LLM_MODEL"\
47+
--set "graphragConfig.GRAPHRAG_LLM_DEPLOYMENT_NAME=$AZURE_AOAI_LLM_MODEL_DEPLOYMENT_NAME" \
48+
--set "graphragConfig.GRAPHRAG_EMBEDDING_MODEL=$AZURE_AOAI_EMBEDDING_MODEL" \
49+
--set "graphragConfig.GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME=$AZURE_AOAI_EMBEDDING_MODEL_DEPLOYMENT_NAME" \
50+
--set "graphragConfig.COGNITIVE_SERVICES_AUDIENCE=$COGNITIVE_SERVICES_AUDIENCE" \
51+
--set "graphragConfig.STORAGE_ACCOUNT_BLOB_URL=$AZURE_STORAGE_ACCOUNT_BLOB_URL"
6152

6253

6354

infra/managed-app/createUiDefinition.json

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,43 @@
159159
"visible": true
160160
}
161161
]
162+
},
163+
{
164+
"name": "StorageaccountSettings",
165+
"label": "StorageAccount Settings",
166+
"subLabel": {
167+
"preValidation": "Configure the graphrag settings",
168+
"postValidation": "Completed"
169+
},
170+
"elements": [
171+
{
172+
"name": "StorageAccountName",
173+
"type": "Microsoft.Common.TextBox",
174+
"label": "Storage Account",
175+
"defaultValue": "",
176+
"toolTip": "StorageAccountName to use",
177+
"visible": true,
178+
"constraints": {
179+
"required": true
180+
}
181+
},
182+
{
183+
"name": "StorageAccountKey",
184+
"type": "Microsoft.Common.PasswordBox",
185+
"label": {
186+
"password": "Storage Account Key",
187+
"confirmPassword": "Confirm Storage Account Key"
188+
},
189+
"constraints": {
190+
"required": true
191+
},
192+
"visible": true
193+
194+
}
195+
196+
]
162197
}
198+
163199
],
164200
"outputs": {
165201
"resourceGroup": "[resourceGroup().name]",
@@ -170,7 +206,9 @@
170206
"embeddingModelName": "[steps('aoaiSettings').embeddingModel]",
171207
"embeddingModelQuota": "[int(steps('aoaiSettings').embeddingModelQuota)]",
172208
"llmModelVersion": "[steps('aoaiSettings').llmModelVersion]",
173-
"embeddingModelVersion": "[steps('aoaiSettings').embeddingModelVersion]"
209+
"embeddingModelVersion": "[steps('aoaiSettings').embeddingModelVersion]",
210+
"publicStorageAccountName": "[steps('StorageaccountSettings').StorageAccountName]",
211+
"publicStorageAccountKey": "[steps('StorageaccountSettings').StorageAccountKey]"
174212
}
175213
}
176214
}

0 commit comments

Comments
 (0)