You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: infra/scripts/copy_kb_files.sh
+17-4Lines changed: 17 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -50,10 +50,23 @@ signed_user_id=$(az ad signed-in-user show --query id -o tsv)
50
50
echo"Getting storage account resource id"
51
51
storage_account_resource_id=$(az storage account show --name $storageAccount --query id --output tsv)
52
52
53
-
# add Storage Blob Data Contributor role to the user
54
-
az role assignment create --assignee $signed_user_id --role "Storage Blob Data Contributor" --scope /$storage_account_resource_id
53
+
#check if user has the Storage Blob Data Contributor role, add it if not
54
+
echo"Checking if user has the Storage Blob Data Contributor role"
55
+
role_assignment=$(MSYS_NO_PATHCONV=1 az role assignment list --assignee $signed_user_id --role "Storage Blob Data Contributor" --scope $storage_account_resource_id --query "[].roleDefinitionId" -o tsv)
56
+
if [ -z"$role_assignment" ];then
57
+
echo"User does not have the Storage Blob Data Contributor role. Assigning the role."
58
+
MSYS_NO_PATHCONV=1 az role assignment create --assignee $signed_user_id --role "Storage Blob Data Contributor" --scope $storage_account_resource_id --output none
59
+
if [ $?-eq 0 ];then
60
+
echo"Role assignment completed successfully."
61
+
else
62
+
echo"Error: Role assignment failed."
63
+
exit 1
64
+
fi
65
+
else
66
+
echo"User already has the Storage Blob Data Contributor role."
67
+
fi
55
68
56
69
# Using az storage blob upload-batch to upload files with managed identity authentication, as the az storage fs directory upload command is not working with managed identity authentication.
0 commit comments