I am trying to access/modify cross account resources using the azure java sdk with the following dependencies
"implementation 'com.azure.resourcemanager:azure-resourcemanager:2.8.0'
implementation 'com.azure:azure-identity:1.4.6'"
I have created an app registration in my account and associated it with a new service principal on the end user's account, created a new role and attached it to the new service principal. I am trying to modify the vm resources on the end user's account now, using the following creds
clientId - my app registration id
clientSecret - secret associated with my app registration
subscriptionId - subscriptionId on the end user account
tenantId - end user's tenant id
I am able to read the vmInfo after logging in from the azure cli using "az login --service-principal -u clientId -p clientSecret --tenant endUserTenantId", but the same fails with above error on my azure sdk code.
My code tries to read vmInfo with,
"vmInfo = azureResourceManager.virtualMachines().getById(vmId);"
Getting error through azure java sdk
Saurabh Pal
1
Reputation point
{"error":{"code":"InvalidAuthenticationToken","message":"The received access token is not valid: at least one of the claims 'puid' or 'altsecid' or 'oid' should be present. If you are accessing as application please make sure service principal is properly created in the tenant."}}
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
1 answer
Sort by: Most helpful
-
Saurabh Pal 1 Reputation point
2022-06-28T06:01:00.227+00:00