Azure CSP Subscription Usage information - azure

Does anyone know if it is possible to retrieve current usage information for a CSP subscription. I have looked at the Partner API but this only gives usage information at a aggregate level. I would like to have information per service running in Azure.

The official microsoft docs provide to use the rest api or C# code for retrieving montly usage based information.
To call this api will give you a monthly usage. https://learn.microsoft.com/en-us/partner-center/develop/get-a-subscriptions-resource-usage-information
GET https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/subscriptions/{id-for-subscription}/usagerecords/resources HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 65b26053-37d0-4303-9fd1-46ad8012bcb6
MS-CorrelationId: 47c36033-af5d-4457-80a4-512c1626fac4

Related

API to retrieve QuickBooks Online General Ledger Data with Azure Data Factory

I'm trying to use Azure Data Factory to connect to QuickBooks Online General Ledger using OAUTH2. My approach is to first create a pipeline with a Web Activity to perform a POST call to receive the authentication token, then create a Copy Activity to read a JSON returned from QuickBooks. My approach is based on this blog. from Alex Volok Consultancy.
I have been unable to use the Web Activity successfully. I am unsure of the parameters and how to configure the Web Activity but have tried many different combinations trying to get this to work.
My desired result is to get QuickBooks Online data into Azure, is this the correct approach?
If this is not the best approach, what is?
If this is the correct approach, the attached screenshot shows my attempt at creating the Web Activity parameters to retrieve the authentication token that is currently not working. Any help is appreciated.
Please follow the below approach. It will solve your problem.
Sample URL : http://restapi.adequateshop.com/api/authaccount/login
Postman:
Using Postman, I generated a bearer Token for testing.
I used the same URL with web Activity and generated a bearer Token in the Azure data factory.
Use Your User id and Password as Body.
Output:
For more information refer this SO Thread and Blog by Ashok Patel

Azure Api Management log user accessed api

Is there any rest api that can be used to fetch api access detail for a user. To know how many times a user accessed a api and how many success or failure request were there. i am not able to use log-to-eventhub.
Thanks to #MayankBargali-MSFT's Q&A answer to similar kind of issue and posting here to help other community members!
Azure APIM will do monitor the APIs published but only listed details are logged as per the APIManagementGatewayLogs.
Based on your requirement, leveage the APIM reporting API and refer to Microsoft Doc for more information on reporting API.
To know who the user accessed particular API in APIM recently, You can call the List by Request API by adding the filter (For example, last 4 days from this day, apiID, etc.).
The above response will provide the details like apiID, timeStamp, userID that helps to find the details.
Still paraphrasing #MayankBargali-MSFT from the post linked above:
To know how many time that user accessed the API, use List by User API where it gives the overall result in which we need to filter with the apiID, then you can get the API Level count.
Point to note here is:
Filter might not work for every column. Therefore, you must modify the outcome at your client's end to perform more filtering and obtain the appropriate result. For further information, kindly consult the relevant API document. As long as you don't delete the APIM instance, the data will continue to be maintained permanently.

Azure Api Management: How to count amount of requests without Subscription Header

My users using AAM API endpoint for a third-party service that requires a webhook - and I need to show usage of this endpoint in User Reports
Third-party API does not support headers and I can't pass Ocp-Apim-Subscription-Key user subscription key to it, and the request will be called anonymously.
As far as I understand that will not allow counting that request in User Reports.
But I can use a token URI parameter to manually get subscription-id and keys for it, with send-request policy.
If I do this is there a way to add the Ocp-Apim-Subscription-Key header to (running?) request in order to perform it on behalf of user subscription?
So far, I can only think about wrapping the required request in another AAM request which will use send-request and set-header policies like that
> POST /endpoint/telegram/public/token123
>> <send-request>GET /token123/keys/primary</send-request>
> POST /endpoint/telegram/token123 +H 'Ocp-Apim-Subscription-Key:key123'
I returned to this question after a couple of days and feel extremely embarrassing now.
To perform a request on behalf of the User I can use the API key in the query instead of the header, there are literally separate setting for that
That solves everything.
You may try to integrate with Application insight to monitor details : How to integrate Azure API Management with Azure Application Insights
Also, you can leverage the metrices to analyze the request pattern.
Based on any condition you may create alert to notify you as well : https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-use-azure-monitor

Not able to get Azure Billing Account Id

I need to get Usage Details at Billing Account Scope for that firstly I used this API but It returns an empty value. I used the Bearer Access token for hitting this API.Is anything other than this am I missed?
Postman Request attached as screenshot
I believe you're using the wrong API. To get Billing info you must provide billing account name:
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}?api-version=2019-10-01-preview
https://learn.microsoft.com/en-us/rest/api/billing/2019-10-01-preview/billingaccounts/get
PS: you can use the "try it" and test if it will return the information you need.
You can also query usage API and use one of the available dimensions to get cost related info:
POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2019-11-01
https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage
This api will return a value if account belongs to Modern billing

How to check azure storage availability through SDK or Rest API?

In my application im trying to get the metrics of azure storage i.e metrics for each of its services(blob,queue,file,table) but before trying to get the metrics i want to check the availability of the storage ,can i do that please suggest.
i want to check if the storage status if its up or down before collecting metrics via SDK
According to your description, I suggest you could send the request to management.azure.com to get your storage account current status by using rest api.
The request is as below:
Get Method:
https://management.azure.com/subscriptions/{yoursubscriptionsID}/resourceGroups/{resourceGroupname}/providers/Microsoft.Storage/storageAccounts/{Youraccount name}?api-version=2017-06-01
Request header:
authorization: Bearer {accesstoken}
More details about how to get the access token(Register your client application with Azure AD, Acquire an access token), you could refer to this article.
Result:
Notice: it will return a json which contains all your storage account current message.
In this json message it contains the statusofPrimary property, this is the status.
Result:
One way of doing it is to invoke the Metadata Rest API's for each of those storage services (blob, queue, table and file). You can go through below links to see the REST API specification that returns the metadata.
Storage - https://learn.microsoft.com/en-us/rest/api/storageservices/setting-and-retrieving-properties-and-metadata-for-blob-resources
Queue - https://learn.microsoft.com/en-us/rest/api/storageservices/get-queue-metadata
Table - https://learn.microsoft.com/en-us/rest/api/storageservices/get-table-service-properties
File - https://learn.microsoft.com/en-us/rest/api/storageservices/get-directory-metadata

Resources