@Emmanuel LETREMBLE , Apologies for the delayed response.
You may try the AZ CLI approach:
az role assignment create `
--assignee-object-id {service principal id} `
--assignee-principal-type ServicePrincipal `
--scope "{cognitive service id}" `
--role "Cognitive Services User"
The user or service that executes the script needs to have the owner or RBAC Admin role.
If you have any further questions, please let us know, I'll be more than happy to follow-up.
If the answer helped (pointed, you in the right direction) > please click Accept Answer - it will benefit the community to find the answers quickly.