Skip to content

Commit f0923b4

Browse files
Update the ReadMe and Added role assignment for Cognitive Services OpenAI User in create_index script
1 parent 19ef66a commit f0923b4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/CustomizingAzdParameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ By default this template will use the environment name as the prefix to prevent
2222
| `AZURE_ENV_EMBEDDING_MODEL_CAPACITY` | integer | `80` | Sets the capacity for the embedding model deployment. |
2323
| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | Guide to get your [Existing Workspace ID](/docs/re-use-log-analytics.md) | Reuses an existing Log Analytics Workspace instead of creating a new one. |
2424
| `AZURE_EXISTING_AI_PROJECT_RESOURCE_ID` | string | Guid to get your existing AI Foundry Project resource ID | Reuses an existing AIFoundry and AIFoundryProject instead of creating a new one. |
25+
| `AZURE_ENV_ACR_NAME` | string | `byocgacontainerreg` | Sets the Azure Container Registry name (allowed value: `byocgacontainerreg`)|
26+
| `AZURE_ENV_OPENAI_LOCATION` | string | `<User selects during deployment>` | Sets the Azure region for OpenAI resource deployment. |
2527

2628

2729
## How to Set a Parameter

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)