my Azure ML api rest return an empty object

Viewed 81

My issue

I try using REST API for machine learning. The following PowerShell doesn't fail, but return an empty objet, whatever the API I am testing. my SPN has contributor permission, I made grant consent and I checked I get a token.

the doc I was using:

https://docs.microsoft.com/fr-fr/rest/api/azureml/quotas/list

I tested several other GET API as well.

I don't know what to do more. Any idea?

My Powershell code

$tenant_id = "XXXXXXXXXXXXXXXXXXX"
$ApplicationId = "XXXXXXXXXXXXXXX"
$spn_client_secret = "XXXXXXXXXXXXX"
$subscriptionid="XXXXXXXXXXXX"
$uri = "https://login.microsoftonline.com/$tenant_id/oauth2/token"

$BodyText = "grant_type=client_credentials&client_id=$ApplicationId&resource=https://management.azure.com&client_secret=$spn_client_secret"

# GET TOKEN
$Response = Invoke-RestMethod -Method POST -Body $BodyText -Uri $URI -ContentType application/x-www-form-urlencoded        
$aad_access_token = $Response.access_token

# tested, I effectively have a token

# READ ml

$urllist = "https://management.azure.com/subscriptions/$subscriptionid/providers/Microsoft.MachineLearningServices/locations/westeurope/quotas?api-version=2021-03-01-preview"

$headers = @{"Authorization" = "Bearer " + $aad_access_token}

Invoke-RestMethod -Method GET -HEADERS $headers -Uri $urllist -ContentType application/x-www-form-urlencoded  
1 Answers

I found what happend and I am a little bit confused.

The resource was empty, because I completely forgot to create a compute!

Related