Can anyone suggest a REST API to fetch all the disks in a subscription according to the disk tier( eg- ultra,standard) and return a list of disks having the same tier.
As far as I know, there is no such API that could retrieve disks by disk tier(SKU) directly . You should filter the result yourself. If you are using .net , use Azure management SDK will be a way that much easier to get the result you need than using REST API.
I write a simple console app for you, try the code below :
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AzureMgmtTest
{
class Program
{
static void Main(string[] args)
{
var subscriotionId = "<azure subscrioption ID>";
var clientId = "<azure ad app id>";
var clientSecret = "<azure ad app secret>";
var tenantId = "<your tenant name/id>";
var sku = "<the disk sku you want to query>"; //all skus : Standard_LRS,Premium_LRS,StandardSSD_LRS,UltraSSD_LRS
var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(clientId,clientSecret,tenantId,AzureEnvironment.AzureGlobalCloud);
var azure = Azure
.Configure()
.Authenticate(credentials)
.WithSubscription(subscriotionId);
Console.WriteLine("using subscription: " + subscriotionId);
var disks = azure.Disks.List().Where(disk => disk.Sku.ToString().Equals(sku));
Console.WriteLine("disks with sku :" + sku);
foreach (var disk in disks) {
Console.WriteLine("name:"+ disk.Name + " resource_group:"+ disk.ResourceGroupName );
}
Console.ReadKey();
}
}
}
Result :
If you have any further concerns, pls feel free to let me know.