Hello Elad Tal
Welcome to Microsoft Q&A Platform, thanks for posting your query here.
Based on internal team suggestion, summarizing below:
Error “The requested identity has not been assigned to this resource" means that the user assigned managed identity (MI) referred by the client_id hasn’t been assigned to your Azure VM yet.
Managed Identity uses IMDS to get access token, you can try testing it from your Azure VM’s Linux shell by running the command below to query IMDS directly and see if you can get an access token by using the same client_id.
CLIENT_ID=<MI_client_id>
curl "[http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=${CLIENT_ID}]" -H Metadata:true -s
If the Managed Identity is assigned to VM correctly you should get an access token. Otherwise, you will be getting “Identity not found” error.
Please refer below document to assign user assigned Managed Identity to VM:
Hope this helps.
If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.