Skip to content

Commit ec9a08a

Browse files
Added Cognitive Services OpenAI User role through Script for Exp issue
1 parent c2ba7d4 commit ec9a08a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

infra/scripts/run_create_index_scripts.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ fi
8383
echo "User already has the Azure AI User role."
8484
fi
8585

86+
### Assign Cognitive Services OpenAI User role to the signed in user ###
87+
88+
# Check if the user has the Cognitive Services OpenAI User role
89+
echo "Checking if user has the Cognitive Services OpenAI User role"
90+
role_assignment=$(MSYS_NO_PATHCONV=1 az role assignment list --role 5e0bd9bd-7b93-4f28-af87-19fc36ad61bd --scope $aif_resource_id --assignee $signed_user_id --query "[].roleDefinitionId" -o tsv)
91+
if [ -z "$role_assignment" ]; then
92+
echo "User does not have the Cognitive Services OpenAI User role. Assigning the role."
93+
MSYS_NO_PATHCONV=1 az role assignment create --assignee $signed_user_id --role 5e0bd9bd-7b93-4f28-af87-19fc36ad61bd --scope $aif_resource_id --output none
94+
if [ $? -eq 0 ]; then
95+
echo "Cognitive Services OpenAI User role assigned successfully."
96+
else
97+
echo "Failed to assign Cognitive Services OpenAI User role."
98+
exit 1
99+
fi
100+
else
101+
echo "User already has the Cognitive Services OpenAI User role."
102+
fi
103+
86104
### Assign Search Index Data Contributor role to the signed in user ###
87105

88106
echo "Getting Azure Search resource id"

0 commit comments

Comments
 (0)