Our Azure DocumentDB is managed by a different team. We don't have access to the Azure Portal. Is there a way for us to see the disk usage of a DocumentCollection? A REST API or .NET API?
You can use client.ReadDocumentCollectionAsync to get this information, e.g.,
ResourceResponse<DocumentCollection> response =
await client.ReadDocumentCollectionAsync(collectionLink);
Console.WriteLine(response.CollectionSizeQuota);
Console.WriteLine(response.CollectionSizeUsage);
See https://msdn.microsoft.com/en-us/library/microsoft.azure.documents.client.documentclient.readdocumentcollectionasync.aspx and https://msdn.microsoft.com/en-us/library/dn799209.aspx for more details.
The equivalent in the REST API is the x-ms-* response headers from GET collection.
Related
I have been following the Azure Service Bus REST API documentation located at https://learn.microsoft.com/en-us/rest/api/servicebus/
I'm required to know the total number of messages in a queue before reading the first message. However, I cannot see a request/command to simply get the total/count number of messages in a given queue.
Is this not possible via the REST API and only available to SDK?
Thanks
You can certainly get this information through REST API. In fact, there are two different REST APIs using which you can get this information.
Using Azure Resource Manager REST API - It is newer and recommended way to work with Service Bus Namespaces. The operation you would want to perform is Queues - Get. The response body will contain the details about the messages count. This API would require you to get an Azure AD access token which is then used for authorization.
Using Old REST API - Though not recommended but you can use old Service Bus REST API to get the information. The operation you would to perform is Get Entity. This API would require you to use your Service Bus Namespace's shared access key for authorization.
Having said this, it is still recommended that you use the SDKs instead of consuming the REST API directly as SDKs are simply wrapper over REST APIs.
Yes you can you need to access it via the management API, more specifically this https://www.nuget.org/packages/Microsoft.Azure.Management.ServiceBus.Fluent/
Here is a great link explaining exactly how to use that package and get the counters you are after
https://www.florinciubotariu.com/retrieving-number-of-messages-in-service-bus-in-net-core/
Trying to understand the different Azure APIs to get the Azure subscription cost details programmatically.
I see RateCard API is good approach. In the output/response of this API , there is something called meterID and meterDetails.
anyone know what is this meterID and meterDetails ? how to get it using Azure Portal ?
The meterID is a GUID for every resource except VMs. meterDetails is the detailed Usage. You can get these details from the cost management section in Azure portal
I'm trying to retrieve Azure cost data for the management group using azure cost usage API.
https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage
But Im getting below error.
"Cost management data is unavailable for subscription xxxxxxxxxxx. The offer MS-AZR-xxxxP is not supported. (Request ID: xxxxx-xxxxx-xxx-xxx-xxxxx)"
Request URL
https://management.azure.com/providers/Microsoft.Management/managementGroups/xxxxxxxxxx/providers/Microsoft.CostManagement/query?api-version=2019-11-01&$top=5000
Is there any way to skip such subsciptions and get data for supported subscriptions using above API.Please assist.
Reason you may be seeing this message is because Azure Cost Management is not supported for all Azure Offer types.
Please check this link for supported/unsupported Azure Offer types for Azure Cost Management: https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/understand-cost-mgt-data#supported-microsoft-azure-offers.
HI i want to monitor Azure Classic VM using REST API/Java SDK , when i tried it with REST API with the following URL(The below url worked for Azure VM)
https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/Preprod2-Resource-Group/providers/Microsoft.ClassicCompute/virtualMachines/cloudops-testvm1/providers/microsoft.insights/metrics?api-version=2016-09-01
I'm getting the following error
{
"code": "NotFound",
"message": "Resource provider not found: [Microsoft.ClassicCompute]"
}
Please suggest me if it can be done via REST API or if there is an SDK please suggest me the same.
My requirement is i want to monitor Classic VM and collect Network In,Network Out,Percentage CPU,Disk Read Operations/Sec,Disk Write Operations/Sec,Disk Write Bytes and Disk Read Bytes for every 5mins
This isn't a supported resource type through metrics API. The supported types and metrics are here:Supported metrics with Azure Monitor. You could check this link, for now, classic VM is not supported.
According to your description, you could use the Metric Definitions API. It works for classic VM.
https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<resourceGroups/>/providers/Microsoft.ClassicCompute/virtualMachines/<Virutal name>/providers/microsoft.insights/metricdefinitions?api-version=2015-07-01
Metric information stores in Azure storage account, you also could call Storage API to get VM metrics. More information please refer to this link:Storage Analytics.
Trying to access metrics such as Requests/sec, Capacity, RUs, etc - programmatically. Have access to API tokens/etc. Not seeing a .NET management nuget package for DocumentDb
TIA
You can read metrics from the Azure Insights SDK. The .NET SDK i currently in preview https://www.nuget.org/packages/Microsoft.Azure.Insights
The Rest API documentation is here https://msdn.microsoft.com/en-us/library/azure/dn931939.aspx?f=255&MSPPError=-2147217396
To list all metrics you can call the following endpoint (you'll need to include the Bearer token in the authorization header)
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resource group of your documentDB}/providers/Microsoft.DocumentDb/databaseAccounts/{documentDB account name}/metricDefinitions?api-version=2015-04-08
This will list all available metric definitions. You can then use a query like this to read the induvidual metrics.
https://management.azure.com/subscriptions/{subecriptionId}/resourceGroups/{resource group}/providers/Microsoft.DocumentDb/databaseAccounts/{DocumentDB account}/metrics?api-version=2015-04-08&$filter=%28name.value%20eq%20%27Total%20Requests%27%29%20and%20timeGrain%20eq%20duration%27PT5M%27%20and%20startTime%20eq%202016-05-28T20%3A26%3A00.0000000Z%20and%20endTime%20eq%202016-05-29T20%3A26%3A00.0000000Z
For more info on reading metrics, see https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/02/23/retrieving-resource-metrics-via-the-azure-insights-api/