Reputation: 11
I have test TSI preview environment in azure connected to an IoTHub. I am experimenting with the TSI test APIs, however, there seems to be something I am doing wrong.
Here are the things that I did.
{ "error": { "code": "ResourceNotFound", "message": "Environment with id 'a5442850-c542-4602-a289-5ec1e1064280' is not found." } }
Any thoughts on whats going wrong?
Upvotes: 1
Views: 550
Reputation: 141
To get a token for the TSI API you need to register an application in your Azure active directory, the command for that is this:
az ad app create --display-name myAppName
// for more options like replyUrls or roles refer to https://learn.microsoft.com/en-us/cli/azure/ad/app?view=azure-cli-latest#az-ad-app-create
or if you want to do it using the portal you can follow these steps here Register Application Using Azure Portal
Next step is to create a password credential for the registered app, using this command in your power-shell
$startDate = Get-Date
$endDate = $startDate.AddYears(3)
$aadAppsecret = New-AzureADApplicationPasswordCredential -ObjectId <ObjectId of your registered application> -CustomKeyIdentifier "myPassword" -StartDate $startDate -EndDate $endDate
If you check the value of $aadAppsecret you should get the password which you will then use in your postman so you need to store it somewhere for later.
If you are unsure of how to get your ObjectId use this command:
az ad app list --display-name myAppName
Next step is to give the application an access to your TSI environment which you have done in your point 2
Finally in your postman do a POST request to
https://login.microsoftonline.com/<Tenant Id>/oauth2/token
And the body of the request should contain the following :
grant_type : client_credentials
client_id : <your registered appId>
client_secret : <the password you generated earlier>
resource: https://api.timeseries.azure.com/
Screenshot of the Postman Request
Upvotes: 3
Reputation: 305
Try using https://login.microsoftonline.com/{tenantId}
remove the /oauth2/token
Upvotes: 0