Create VM in Microsoft Azure using JAVA -


i want create vms in microsoft azure using java rest api. this, getting access token using microsoft login credentials passing below values:

grant_type: client_credentials, client_id: {my_client}, client_secret: {my_client_secret}, resource:{http://localhost} 

then getting big access key. calling create vm rest api using access key. unauthorised error below.

"code": "invalidauthenticationtokenaudience",  "message": "the access token has been obtained wrong audience or resource 'http://localhost'. 

it should match (including forward slash) 1 of allowed audiences 'http://localhost','http://localhost'."

how correctly call microsoft azure authentication , create vm using java? there way achieve authorization through certificate? steps?

it seems might use incorrect urls azure resource management.

according the offical example in java create vm, can see urls below in code comment requesting access token.

/**      * create vm virtualnetwork , storage account      * within subscription using service principal authentication.      * use sample please set following environment variable or replace getenv call      * actual value:      *      management.uri=https://management.core.windows.net/      arm.url=https://management.azure.com/      arm.aad.url=https://login.windows.net/      arm.clientid=[your service principal client id]      arm.clientkey=[your service principal client key]      arm.tenant=[your service principal tenant]      management.subscription.id=[your subscription id (guid)]      *      * @param args arguments supplied @ command line (they not used)      * @throws exception of exceptions!!      */ 

you can try refer other example serviceprincipalexample.java check code whether urls & ids correct.

hope helps. best regards.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -