我的问题
我尝试使用 REST API 进行机器学习。无论我正在测试什么 API,以下 PowerShell 都不会失败,但会返回一个空对象。 我的 SPN 具有贡献者权限,我已授予同意并检查我是否获得了 token 。
我正在使用的文档:
https://learn.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
最佳答案
我发现发生了什么事,我有点困惑。
资源是空的,因为我完全忘记创建计算!
关于azure - 我的 Azure ML api 其余部分返回一个空对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69906308/