graphrag-accelerator icon indicating copy to clipboard operation
graphrag-accelerator copied to clipboard

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

Open cynthiajiangatl opened this issue 1 year ago • 4 comments

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" }

cynthiajiangatl avatar Aug 09 '24 00:08 cynthiajiangatl

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?

timothymeyers avatar Aug 09 '24 15:08 timothymeyers

@cynthiajiangatl Are you using Linux?

rnpramasamyai avatar Aug 10 '24 02:08 rnpramasamyai

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

cynthiajiangatl avatar Sep 04 '24 14:09 cynthiajiangatl

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 ...

rm-1997 avatar Sep 10 '24 08:09 rm-1997