You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> If you register an application in the Azure portal, this step is completed for you.
221
221
222
222
3. The last step is to [assign the "Cognitive Services User" role](/powershell/module/az.Resources/New-azRoleAssignment) to the service principal (scoped to the resource). By assigning a role, you're granting service principal access to this resource. You can grant the same service principal access to multiple resources in your subscription.
223
-
>[!NOTE]
223
+
224
+
> [!NOTE]
224
225
> The ObjectId of the service principal is used, not the ObjectId for the application.
225
226
> The ACCOUNT_ID will be the Azure resource Id of the Azure AI services account you created. You can find Azure resource Id from "properties" of the resource in Azure portal.
226
227
@@ -239,32 +240,31 @@ In this sample, a password is used to authenticate the service principal. The to
239
240
```
240
241
241
242
2. Get a token:
242
-
> [!NOTE]
243
-
> If you're using Azure Cloud Shell, the `SecureClientSecret` class isn't available.
$responseToken = Invoke-RestMethod -Uri $tokenEndpoint -Method Post -Body $body
258
+
$accessToken = $responseToken.access_token
259
+
```
263
260
261
+
> [!NOTE]
262
+
> Anytime you use passwords in a script, the most secure option is to use the PowerShell Secrets Management module and integrate with a solution such as Azure KeyVault.
263
+
264
264
3. Call the Computer Vision API:
265
265
```powershell-interactive
266
266
$url = $account.Endpoint+"vision/v1.0/models"
267
-
$result = Invoke-RestMethod -Uri $url -Method Get -Headers @{"Authorization"=$token.CreateAuthorizationHeader()} -Verbose
0 commit comments