Skip to content

Commit d013d4b

Browse files
committed
Attempt to assign data reader role to MI
1 parent 1ac9271 commit d013d4b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/aks-as-mgmt.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ create_aks_cluster() {
201201
sleep 5
202202
done
203203

204+
# If storage account var is set:
205+
if [ -n "${AZURE_STORAGE_ACCOUNT}" ]; then
206+
echo "assigning storage blob data reader role to the service principal"
207+
until az role assignment create --assignee-object-id "${AKS_MI_OBJECT_ID}" --role "Storage Blob Data Reader" \
208+
--scope "/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${AZURE_STORAGE_ACCOUNT_RESOURCE_GROUP}/providers/Microsoft.Storage/storageAccounts/${AZURE_STORAGE_ACCOUNT}/blobServices/default/containers/${AZURE_BLOB_CONTAINER_NAME}" \
209+
--assignee-principal-type ServicePrincipal; do
210+
echo "retrying to assign storage blob data reader role to the service principal"
211+
sleep 5
212+
done
213+
fi
214+
204215
echo "using ASO_CREDENTIAL_SECRET_MODE as podidentity"
205216
ASO_CREDENTIAL_SECRET_MODE="podidentity"
206217
}

0 commit comments

Comments
 (0)