How to pull Azure Cognitive Search Quota and usage? - azure

I am trying to pull azure cognitive search current and quota .
Can anyone help me on:
" how can I get that information to csv using some service principle."
I found one link to pull this kind of data :
https://learn.microsoft.com/en-us/rest/api/searchservice/get-service-statistics
But I am not sure how to use this api to get above screenshot information.

The link you posted is the correct way to do it, it returns all the information you need.
It looks like this endpoint does not support OAuth2 & RBAC. So instead of using service principal, you need to provide the admin api-key in the request header.
You can check here how to access the api-key. If you'll be doing that from a powershell script, you can authenticate with your service principal and fetch the key using Get-AzSearchAdminKeyPair, then use this key to make a http request to get the statistics and finally convert them to CSV format.

Related

Get list of all user from Azure Devops

i try to get list of all users from Azure Devops with postman,
i tried this link : https://titi.net/{organization}/_apis/graph/users/{userDescriptor}?api-version=6.0-preview.1&userDescriptor=username&organization=titiproject
Please check if my finding helps ,
To get users using user descriptor we can use the below given API:-
e.g:-
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users/{userDescriptor}?api-version=6.0-preview.1
For more information please refer this MICROSOFT DOCUMENTATION|Get a user by its descriptor & Use Postman with the Microsoft Graph API

Querying multiple application insights resources with REST API

I'm trying to query two different application insight instances (instance A and B) trough the REST API. I'm using postman to send a GET http request to the API and followed the answer in this post, which was aiming towards the same goal, join request data from different applications insights: https://stackoverflow.com/a/52248597/17161618
Just as it says in the above mentioned post I'm acessing the instance A and passed the authentication through the request header in the format keyA:appIdA,KeyB:appIdB.
I'm sending the following query:" union app("AppIdA").traces,app("AppIdB").traces " and receive the following error: enter image description here
Does anyone know how can I get access to read logs in resource B ?
I don't think you can run cross-component queries using API keys. You should use AAD (Azure Active Directory) auth. Give AAD app access to both resources. Then you should be able to run such queries.

How to use Power BI REST API's in Azure Data Factory

I am trying to create a list of all the workspaces and the reports contained in each one of them for a documentation project.
I found online that we can use this to get the workspaces, I wanna use it with a "web" activity:
https://api.powerbi.com/v1.0/myorg/groups
And then I want to use the IDs we get in the output with a foreach and another web activity inside of it and use this to get the reports in each workspace, then copy it somewhere (datalake or DB) :
https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports
But I don't know how to configure the activity and the authentication.
If there is a better way like connecting directly to Power BI I'm all ears, I tried to do a get data from web source but I don't have any "key" for API and organization authentication doesn't work.
When I run the code here: https://learn.microsoft.com/en-us/rest/api/power-bi/groups/getgroups it works perfectly.
Thanks in advance
'But I don't know how to configure the activity and the authentication.' For this question, I'm not sure if you don't know how to use access token to call an API.
Register an azure ad application with the api permission of 'https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All'
so that you can generate an access token by this application with
this scope. Add api permission.
Use ropc flow to generate an access token. This flow contains user information so that your api could know who you are to return correct groups.
Add 'Authorization' in request head with value of 'Bearer accessToken' to call the api.
ropc flow 1.0:

Is there a way to get Azure Subscription ID programmatically?

We would like to create some Azure resources using Azure Rest APIs through a C# program. We are able to get access token by following the below msdn doc
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code .
But the Azure Rest APIs also requires Subscription ID which we are not able to get. Is there a way we can get it through program?
Thanks
Balaji
You can use the below request URI to get list of subscriptions for a tenant. https://management.azure.com/subscriptions?api-version=2016-06-01
Please refer to Get Subscription List for more information.

Microsoft Cognitive Services - Computer Vision: Invalid Subscription Key

I'm trying to use the Computer Vision API from Microsoft's Cognitive Services. However, my keys don't seem to be working. I created an account using the free trial of that API and got the two keys from it. Trying to use the key with the ProjectOxford.Vision SDK always yields:
Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription.
I tried the API console, however I get the same error with my key in the Ocp-Apim-Subscription-Key field. I tried both keys and neither of them work. I even got the free version of Face API and tried its console, but encountered the same issue with its keys. I even tried different datacenters, but they all seem to return the same error.
This would need to be some problem with the key then right? This can't be a problem with my C# code, since the console doesn't work either. And since it's failing in the API console, there's nothing more I can do to rule out any other possibilities is there? I'm not sure what else I can do to debug this. I'd like to regenerate my keys (I saw a tutorial video which showed an older UI of getting the API keys and they used to have a "regenerate" link) but I don't see a way of doing that anymore.
I only just made the account and registered for the APIs, so there's no way I'd be over quota. Is there something else I need to do to enable these keys or something?
I managed to skirt around the issue of 'Access Denied' by performing the following actions:
I created a free Azure account
I set up an instance of the Cognitive Services Api (this generated a pair of new keys for me to use)
Utilizing the new key, I had to use the following link:
https://westus.api.cognitive.microsoft.com/vision/v1.0/ocr
Instead of
https://westus.api.cognitive.microsoft.com/vision/v1.0/recognizeText
(I obtained this link from the Cognitive Services Test Dashboard).
Look at the request pattern on the test dashboard and you should be able to tell how to use the api.
Even when #Xuan Hu response states correctly to the solution, I scratched my head some time trying to figure out how to change the end point. Here are my 2 cents:
Go to portal.azure.com, in the dashboard of your subscription to the Cognitive Services > General Information > End Point take note of the URL. You need it.
Find in the code of your VisionAPI samples where the VisionServiceClient is instantiated:
VisionServiceClient VisionServiceCliente = new VisionServiceClient(SubscriptionKey);
and change including the URL that you found in Azure:
VisionServiceClient VisionServiceCliente = new VisionServiceClient(SubscriptionKey, StringOfMyURLTakedFromPortal);
That worked for me.
If you are using the free trial keys got from azure.microsoft.com. You need to change the API endpoint region to westcentralus. The previous default region is westus and I think that is the reason of the invalid key problem.
FYI, there is a blog post that covers all of the 401 Access Denied scenarios, including this one regarding the free API keys and region specific API endpoint. Adding it here for folks in the future who find this SO post - https://blogs.msdn.microsoft.com/kwill/2017/05/17/http-401-access-denied-when-calling-azure-cognitive-services-apis/.
Using the incorrect regional endpoint
Most of the Cognitive Services APIs are region specific, which means that during API account creation you select which region you want to create the account in. These APIs have region specific endpoints such as westus.api.cognitive.microsoft.com or eastus2.api.cognitive.microsoft.com, and an API key for an account created in one region will only work using the endpoint for that specific region. This means that if you create an API account in West US you will not be able to call the eastus2.api.cognitive.microsoft.com API endpoint.
You can verify the region and endpoint in the Azure management portal.
Trial API Keys
The free trial API keys have 30 day expiration dates, and the same restrictions for region and version. If you are using the trial keys you can go to https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/ to manage your API keys (if you are not already logged in then just click one of the ‘Create’ buttons and you can go through the wizard to login and see your existing API keys), and you will also see the expiration date and endpoint.
One thing to remember if using Postman to get the results is to use GET and put your keys in the Header.

Resources