mirror of
https://github.com/Azure-Samples/graphrag-accelerator.git
synced 2025-10-13 09:48:46 +00:00
Predeploy SKU validation (#182)
Co-authored-by: Kenny Zhang <zhangken@microsoft.com> Co-authored-by: Gabriel Nieves-Ponce <39567323+nievespg1@users.noreply.github.com>
This commit is contained in:
parent
58b2a414a7
commit
67e52e3d18
@ -114,6 +114,18 @@ exitIfValueEmpty () {
|
||||
fi
|
||||
}
|
||||
|
||||
exitIfThresholdExceeded () {
|
||||
local value=$1
|
||||
local threshold=$2
|
||||
local msg=$3
|
||||
# throw an error if input value exceeds threshold
|
||||
if [ $value -ge $threshold ]; then
|
||||
errorBanner
|
||||
printf "$msg\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
versionCheck () {
|
||||
# assume the version is in the format major.minor.patch
|
||||
local TOOL=$1
|
||||
@ -337,6 +349,53 @@ deployAzureResources () {
|
||||
assignAOAIRoleToManagedIdentity
|
||||
}
|
||||
|
||||
validateSKUs() {
|
||||
# Run SKU validation functions unless skip flag is set
|
||||
if [ $2 = true ]; then
|
||||
checkSKUAvailability $1
|
||||
checkSKUQuotas $1
|
||||
fi
|
||||
}
|
||||
|
||||
checkSKUAvailability() {
|
||||
# Function to validate that the required SKUs are not restricted for the given region
|
||||
printf "Checking Location for SKU Availability... "
|
||||
local location=$1
|
||||
local sku_checklist=("standard_d4s_v5" "standard_d8s_v5" "standard_e8s_v5")
|
||||
for sku in ${sku_checklist[@]}; do
|
||||
local sku_check_result=$(
|
||||
az vm list-skus --location $location --size $sku --output json
|
||||
)
|
||||
local sku_validation_listing=$(jq -r .[0].name <<< $sku_check_result)
|
||||
exitIfValueEmpty $sku_validation_listing "SKU $sku is restricted for location $location under the current subscription."
|
||||
done
|
||||
printf "Done.\n"
|
||||
}
|
||||
|
||||
checkSKUQuotas() {
|
||||
# Function to validation that the SKU quotas would not be exceeded during deployment
|
||||
printf "Checking Location for SKU Quota Usage... "
|
||||
local location=$1
|
||||
local vm_usage_report=$(
|
||||
az vm list-usage --location $location
|
||||
)
|
||||
|
||||
# Check quota for Standard DSv5 Family vCPUs
|
||||
local dsv5_usage_report=$(jq -c '.[] | select(.localName | contains("Standard DSv5 Family vCPUs"))' <<< $vm_usage_report)
|
||||
local dsv5_limit=$(jq -r .limit <<< $dsv5_usage_report)
|
||||
local dsv5_currVal=$(jq -r .currentValue <<< $dsv5_usage_report)
|
||||
local dsv5_reqVal=$(expr $dsv5_currVal + 12)
|
||||
exitIfThresholdExceeded $dsv5_reqVal $dsv5_limit "Not enough Standard DSv5 Family vCPU quota for deployment."
|
||||
|
||||
# Check quota for Standard ESv5 Family vCPUs
|
||||
local esv5_usage_report=$(jq -c '.[] | select(.localName | contains("Standard ESv5 Family vCPUs"))' <<< $vm_usage_report)
|
||||
local esv5_limit=$(jq -r .limit <<< $esv5_usage_report)
|
||||
local esv5_currVal=$(jq -r .currentValue <<< $esv5_usage_report)
|
||||
local esv5_reqVal=$(expr $esv5_currVal + 8)
|
||||
exitIfThresholdExceeded $esv5_reqVal $esv5_limit "Not enough Standard ESv5 Family vCPU quota for deployment."
|
||||
printf "Done.\n"
|
||||
}
|
||||
|
||||
assignAOAIRoleToManagedIdentity() {
|
||||
printf "Assigning 'Cognitive Services OpenAI Contributor' role to managed identity... "
|
||||
local servicePrincipalId=$(jq -r .azure_workload_identity_principal_id.value <<< $AZURE_OUTPUTS)
|
||||
@ -570,12 +629,13 @@ deployDockerImageToACR() {
|
||||
################################################################################
|
||||
usage() {
|
||||
echo
|
||||
echo "Usage: bash $0 [-h|d|g] -p <deploy.parameters.json>"
|
||||
echo "Usage: bash $0 [-h|d|g|s] -p <deploy.parameters.json>"
|
||||
echo "Description: Deployment script for the GraphRAG Solution Accelerator."
|
||||
echo "options:"
|
||||
echo " -h Print this help menu."
|
||||
echo " -d Disable private endpoint usage."
|
||||
echo " -g Developer mode. Grants deployer of this script access to Azure Storage, AI Search, and CosmosDB. Will disable private endpoints (-d) and enable debug mode."
|
||||
echo " -s Skip validation of SKU availability and quota for a faster deployment"
|
||||
echo " -p A JSON file containing the deployment parameters (deploy.parameters.json)."
|
||||
echo
|
||||
}
|
||||
@ -583,9 +643,10 @@ usage() {
|
||||
[ $# -eq 0 ] && usage && exit 0
|
||||
# parse arguments
|
||||
ENABLE_PRIVATE_ENDPOINTS=true
|
||||
VALIDATE_SKUS_FLAG=true
|
||||
GRANT_DEV_ACCESS=0 # false
|
||||
PARAMS_FILE=""
|
||||
while getopts ":dgp:h" option; do
|
||||
while getopts ":dgsp:h" option; do
|
||||
case "${option}" in
|
||||
d)
|
||||
ENABLE_PRIVATE_ENDPOINTS=false
|
||||
@ -594,6 +655,9 @@ while getopts ":dgp:h" option; do
|
||||
ENABLE_PRIVATE_ENDPOINTS=false
|
||||
GRANT_DEV_ACCESS=1 # true
|
||||
;;
|
||||
s)
|
||||
VALIDATE_SKUS_FLAG=false
|
||||
;;
|
||||
p)
|
||||
PARAMS_FILE=${OPTARG}
|
||||
;;
|
||||
@ -626,6 +690,7 @@ createSshkeyIfNotExists $RESOURCE_GROUP
|
||||
|
||||
# Deploy Azure resources
|
||||
checkForApimSoftDelete
|
||||
validateSKUs $LOCATION $VALIDATE_SKUS_FLAG
|
||||
deployAzureResources
|
||||
|
||||
# Deploy the graphrag backend docker image to ACR
|
||||
|
Loading…
x
Reference in New Issue
Block a user