1

我的问题

我尝试使用 REST API 进行机器学习。无论我正在测试什么 API,以下 PowerShell 都不会失败,但会返回一个空对象。我的 SPN 有贡献者许可,我同意并检查我得到了一个令牌。

我正在使用的文档:

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

我还测试了其他几个 GET API。

我不知道该怎么做更多。任何想法?

我的 Powershell 代码

$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  
4

1 回答 1

0

我发现发生了什么,我有点困惑。

资源是空的,因为我完全忘记了创建计算!

于 2021-11-11T09:11:38.430 回答