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

Commit 5534ef3

Browse files
authored
Merge branch 'main' into anevjes/bicep-fixes
2 parents d54b00f + 825750b commit 5534ef3

File tree

6 files changed

+38
-20
lines changed

6 files changed

+38
-20
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ RUN apt-get update && apt-get install -y \
2828
software-properties-common
2929
# install Azure CLI
3030
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
31-
RUN az bicep install
32-
# install kubectl
33-
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
34-
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
31+
# install bicep and kubectl
32+
RUN az bicep install && az aks install-cli
3533
# install helm
3634
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \
3735
&& chmod 700 get_helm.sh \

docker/Dockerfile-backend

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ RUN cd backend \
2020
# download all nltk data that graphrag requires
2121
RUN python -m nltk.downloader punkt averaged_perceptron_tagger maxent_ne_chunker words wordnet
2222

23-
# Note: we temporarily patch the adlfs library to enable use of managed identity. A PR has been submitted to the adlfs library.
24-
# See https://github.com/fsspec/adlfs/pull/480
25-
# TODO: remove this once PR has been merged and a new version released
26-
RUN sed -i '/self.credential = credential/a\ \ \ \ \ \ \ \ if kwargs.get("account_host"): self.account_host = kwargs.get("account_host")' /usr/local/lib/python3.10/site-packages/adlfs/spec.py
27-
2823
WORKDIR /backend
2924
EXPOSE 80
3025
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "80"]

docs/DEPLOYMENT-GUIDE.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ In the `deploy.parameters.json` file, provide values for the following required
7878

7979
| Variable | Expected Value | Required | Description
8080
| :--- | :--- | --- | ---: |
81-
`RESOURCE_GROUP` | <my_resource_group> | Yes | The resource group that GraphRAG will be deployed in. Will get created automatically if the resource group does not exist.
82-
`LOCATION` | <my_location> | Yes | The azure cloud region to deploy GraphRAG resources in.
83-
`CONTAINER_REGISTRY_NAME` | <my_container_registry_name> | No | Name of an Azure Container Registry where the `graphrag` backend docker image will be hosted. Leave off `.azurecr.io` from the name. If not provided, a unique name will be generated (recommended).
84-
`GRAPHRAG_IMAGE` | graphrag:backend | No | The name and tag of the graphrag docker image in the container registry. Will default to `graphrag:backend` and be hosted at `my_container_registry_name>.azurecr.io/graphrag:backend`.
8581
`GRAPHRAG_API_BASE` | https://<my_openai_name>.openai.azure.com | Yes | Azure OpenAI service endpoint.
8682
`GRAPHRAG_API_VERSION` | 2023-03-15-preview | Yes | Azure OpenAI API version.
87-
`GRAPHRAG_LLM_MODEL` | gpt-4 | Yes | Name of the gpt-4 turbo model.
88-
`GRAPHRAG_LLM_DEPLOYMENT_NAME` | | Yes | Deployment name of the gpt-4 turbo model.
89-
`GRAPHRAG_EMBEDDING_MODEL` | text-embedding-ada-002 | Yes | Name of the Azure OpenAI embedding model.
9083
`GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME` | | Yes | Deployment name of the Azure OpenAI embedding model.
84+
`GRAPHRAG_EMBEDDING_MODEL` | text-embedding-ada-002 | Yes | Name of the Azure OpenAI embedding model.
85+
`GRAPHRAG_LLM_DEPLOYMENT_NAME` | | Yes | Deployment name of the gpt-4 turbo model.
86+
`GRAPHRAG_LLM_MODEL` | gpt-4 | Yes | Name of the gpt-4 turbo model.
87+
`LOCATION` | <my_location> | Yes | The azure cloud region to deploy GraphRAG resources to (can be different than the location of your AOAI instance). Please use the [compressed form](https://azuretracks.com/2021/04/current-azure-region-names-reference) of a cloud region name (i.e. `eastus2`).
88+
`RESOURCE_GROUP` | <my_resource_group> | Yes | The resource group that GraphRAG will be deployed in. Will get created automatically if the resource group does not exist.
89+
`GRAPHRAG_IMAGE` | graphrag:backend | No | The name and tag of the graphrag docker image in the container registry. Will default to `graphrag:backend` and be hosted at `my_container_registry_name>.azurecr.io/graphrag:backend`.
90+
`CONTAINER_REGISTRY_NAME` | <my_container_registry_name> | No | Name of an Azure Container Registry where the `graphrag` backend docker image will be hosted. Leave off `.azurecr.io` from the name. If not provided, a unique name will be generated (recommended).
9191
`GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT` | | No | Endpoint for cognitive services identity authorization. Will default to `https://cognitiveservices.azure.com/.default` for Azure Commercial cloud but should be defined for deployments in other Azure clouds.
9292
`APIM_NAME` | | No | Hostname of the API. Must be a globally unique name. The API will be accessible at `https://<APIM_NAME>.azure-api.net`. If not provided a unique name will be generated.
9393
`APIM_TIER` | | No | The [APIM tier](https://azure.microsoft.com/en-us/pricing/details/api-management) to use. Must be either `Developer` or `StandardV2`. Will default to `Developer` for cost savings.

infra/core/aks/aks.bicep

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ param systemOsDiskSizeGB int = 128
3030
param systemNodeCount int = 1
3131

3232
@description('The size of the system Virtual Machine.')
33-
param systemVMSize string = 'standard_d4s_v5'
33+
param systemVMSize string = 'standard_d4s_v5' // 4 vcpu, 16 GB memory
3434

3535
@description('The number of nodes for the graphrag node pool.')
3636
@minValue(1)
@@ -62,6 +62,8 @@ param ingressRoleAssignments array = []
6262
@description('Array of objects with fields principalType, roleDefinitionId')
6363
param systemRoleAssignments array = []
6464

65+
@description('Array of object ids that will have admin role of the cluster')
66+
param clusterAdmins array = []
6567

6668
resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = {
6769
name: privateDnsZoneName
@@ -76,6 +78,11 @@ resource aks 'Microsoft.ContainerService/managedClusters@2024-02-01' = {
7678
properties: {
7779
enableRBAC: true
7880
dnsPrefix: !empty(dnsPrefix) ? dnsPrefix : toLower(clusterName)
81+
aadProfile: {
82+
managed: true
83+
enableAzureRBAC: true
84+
adminGroupObjectIDs: clusterAdmins
85+
}
7986
addonProfiles: {
8087
omsagent: {
8188
enabled: true

infra/deploy.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,16 @@ getAksCredentials () {
297297
printf "Getting AKS credentials... "
298298
az aks get-credentials -g $rg -n $aks --overwrite-existing 2>&1
299299
exitIfCommandFailed $? "Error getting AKS credentials, exiting..."
300+
kubelogin convert-kubeconfig -l azurecli
301+
exitIfCommandFailed $? "Error logging into AKS, exiting..."
302+
# get principal/object id of the signed in user
303+
local principalId=$(az ad signed-in-user show --output json | jq -r .id)
304+
exitIfValueEmpty $principalId "Principal ID of deployer not found"
305+
# assign "Azure Kubernetes Service RBAC Admin" role to deployer
306+
local scope=$(az aks show --resource-group $rg --name $aks --query "id" -o tsv)
307+
exitIfValueEmpty "$scope" "Unable to get AKS scope, exiting..."
308+
az role assignment create --role "Azure Kubernetes Service RBAC Cluster Admin" --assignee-object-id $principalId --scope $scope
309+
exitIfCommandFailed $? "Error assigning 'Azure Kubernetes Service RBAC Cluster Admin' role to deployer, exiting..."
300310
kubectl config set-context $aks --namespace=$aksNamespace
301311
printf "Done\n"
302312
}
@@ -326,6 +336,9 @@ deployAzureResources () {
326336
echo "Deploying Azure resources..."
327337
local SSH_PUBLICKEY=$(jq -r .publicKey <<< $SSHKEY_DETAILS)
328338
exitIfValueEmpty "$SSH_PUBLICKEY" "Unable to read ssh publickey, exiting..."
339+
# get principal/object id of the signed in user
340+
local deployerPrincipalId=$(az ad signed-in-user show --output json | jq -r .id)
341+
exitIfValueEmpty $deployerPrincipalId "Principal ID of deployer not found"
329342
local datetime="`date +%Y-%m-%d_%H-%M-%S`"
330343
local deployName="graphrag-deploy-$datetime"
331344
echo "Deployment name: $deployName"
@@ -342,6 +355,7 @@ deployAzureResources () {
342355
--parameters "publisherEmail=$PUBLISHER_EMAIL" \
343356
--parameters "enablePrivateEndpoints=$ENABLE_PRIVATE_ENDPOINTS" \
344357
--parameters "acrName=$CONTAINER_REGISTRY_NAME" \
358+
--parameters "deployerPrincipalId=$deployerPrincipalId" \
345359
--output json)
346360
# errors in deployment may not be caught by exitIfCommandFailed function so we also check the output for errors
347361
exitIfCommandFailed $? "Error deploying Azure resources..."
@@ -390,14 +404,14 @@ checkSKUQuotas() {
390404
local dsv5_limit=$(jq -r .limit <<< $dsv5_usage_report)
391405
local dsv5_currVal=$(jq -r .currentValue <<< $dsv5_usage_report)
392406
local dsv5_reqVal=$(expr $dsv5_currVal + 12)
393-
exitIfThresholdExceeded $dsv5_reqVal $dsv5_limit "Not enough Standard DSv5 Family vCPU quota for deployment."
407+
exitIfThresholdExceeded $dsv5_reqVal $dsv5_limit "Not enough Standard DSv5 Family vCPU quota for deployment. At least 12 vCPU is required."
394408

395409
# Check quota for Standard ESv5 Family vCPUs
396410
local esv5_usage_report=$(jq -c '.[] | select(.localName | contains("Standard ESv5 Family vCPUs"))' <<< $vm_usage_report)
397411
local esv5_limit=$(jq -r .limit <<< $esv5_usage_report)
398412
local esv5_currVal=$(jq -r .currentValue <<< $esv5_usage_report)
399413
local esv5_reqVal=$(expr $esv5_currVal + 8)
400-
exitIfThresholdExceeded $esv5_reqVal $esv5_limit "Not enough Standard ESv5 Family vCPU quota for deployment."
414+
exitIfThresholdExceeded $esv5_reqVal $esv5_limit "Not enough Standard ESv5 Family vCPU quota for deployment. At least 8 vCPU is required."
401415
printf "Done.\n"
402416
}
403417

@@ -579,7 +593,7 @@ grantDevAccessToAzureResources() {
579593

580594
# get principal/object id of the signed in user
581595
local principalId=$(az ad signed-in-user show --output json | jq -r .id)
582-
exitIfValueEmpty $principalId "Principal ID not found"
596+
exitIfValueEmpty $principalId "Principal ID of deployer not found"
583597

584598
# assign storage account roles
585599
local storageAccountName=$(az storage account list --resource-group $RESOURCE_GROUP --output json | jq -r .[0].name)

infra/main.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ param graphRagName string
2929
@description('Cloud region for all resources')
3030
param location string = resourceGroup().location
3131

32+
@description('Principal/Object ID of the deployer. Will be used to assign admin roles to the AKS cluster.')
33+
param deployerPrincipalId string
34+
3235
@minLength(1)
3336
@description('Name of the publisher of the API Management instance.')
3437
param publisherName string
@@ -188,6 +191,7 @@ module aks 'core/aks/aks.bicep' = {
188191
location: location
189192
graphragVMSize: 'standard_d8s_v5' // 8 vcpu, 32 GB memory
190193
graphragIndexingVMSize: 'standard_e8s_v5' // 8 vcpus, 64 GB memory
194+
clusterAdmins: ['${deployerPrincipalId}']
191195
sshRSAPublicKey: aksSshRsaPublicKey
192196
logAnalyticsWorkspaceId: log.outputs.id
193197
subnetId: vnet.properties.subnets[1].id // aks subnet

0 commit comments

Comments
 (0)