Azure-Samples / graphrag-accelerator

One-click deploy of a Knowledge Graph powered RAG (GraphRAG) in Azure
https://github.com/microsoft/graphrag
MIT License
1.65k stars 250 forks source link

[FEATURE] Add AOAI resource group to use existing AOAI service #132

Open cynthiajiangatl opened 1 month ago

cynthiajiangatl commented 1 month ago

Need to add resource group for AOAI service to avoid deployment errors.

For existing Azure OpenAI service, it may not be in the newly created resource group, needs to add AOAI_RESOURCE_GROUP in deploy.parameters.json and update the deploy.sh in a couple of places.

requiredParams=( LOCATION GRAPHRAG_API_BASE GRAPHRAG_API_VERSION GRAPHRAG_LLM_MODEL GRAPHRAG_LLM_DEPLOYMENT_NAME GRAPHRAG_EMBEDDING_MODEL GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME RESOURCE_GROUP AOAI_RESOURCE_GROUP )

deployAzureResources () { echo "Deploying Azure resources..." local SSH_PUBLICKEY=$(jq -r .publicKey <<< $SSHKEY_DETAILS) exitIfValueEmpty "$SSH_PUBLICKEY" "Unable to read ssh publickey, exiting..." local aoaiName=$(az cognitiveservices account list -g $AOAI_RESOURCE_GROUP --query "[?contains(properties.endpoint, '$GRAPHRAG_API_BASE')] | [0].name" -o tsv) exitIfValueEmpty "$aoaiName" "Unable to retrieve AOAI name from GRAPHRAG_API_BASE, exiting..."

assignAOAIRoleToManagedIdentity() { printf "Assigning 'Cognitive Services OpenAI Contributor' role to managed identity... " local servicePrincipalId=$(jq -r .azure_workload_identity_principal_id.value <<< $AZURE_OUTPUTS) exitIfValueEmpty "$servicePrincipalId" "Unable to parse service principal id from azure outputs, exiting..." local scope=$(az cognitiveservices account list -g $AOAI_RESOURCE_GROUP --query "[?contains(properties.endpoint, '$GRAPHRAG_API_BASE')] | [0].id" -o tsv) az role assignment create --only-show-errors --role "Cognitive Services OpenAI Contributor" --assignee "$servicePrincipalId" --scope "$scope" > /dev/null 2>&1 exitIfCommandFailed $? "Error assigning role to service principal, exiting..." printf "Done.\n" }

timothymeyers commented 1 month ago

Hi @cynthiajiangatl - I've never run into any deployment errors when deploying with my AOAI resource in a different RG.

The az cognitiveservices account list command should return all AOAI resources that match the endpoint provided, regardless of RG.

I'm not sure this is needed?

rnpramasamyai commented 1 month ago

@cynthiajiangatl Are you using Linux?

cynthiajiangatl commented 1 week ago

I was deploying it from an AML compute instance. Yes, it is Linux.

stefan-1997 commented 5 days ago

For me all works fine, BUT: why do the azure open ai resource (and its models) have to be created (deployed) in advance? Why are they not part of the general deployment code (i.e. main.bicep and deploy.sh). I am just asking to get a better understanding here ...