Hi @Gautam De ,
Thank you for posting this in Microsoft Q&A.
I understand you got the error "Role assignment creation failed & subscription identifier is malformed or invalid" while creating service principal.
You may encounter the "Role assignment creation failed" error when incorrect values or parameters are being passed to create the service principal and rbac for service principal.
Noticed someone have posted similar query in stack overflow https://stackoverflow.com/questions/77466378/why-did-role-assignment-creation-failed where one of the community members have answered it. I am updating the same here if anyone looking for similar issue on QnA will help them.
Hope this helps. Do let us know if you any further queries.
Thanks,
Navya.
If the answer is helpful, please click "Accept Answer" and kindly upvote it.