Reputation: 43
I want to get a List with all possible AppService Hosting Plan configuration settings of my Azure subscription(Location, Tier, Size,...). Possibly through skus.
var skus = await AppServiceExtensions.GetSkusAsync(subscription);
if (hostingPlanSkus != null)
{
Console.WriteLine("Available App Service SKUs:");
foreach (var sku in hostingPlanSkus)
{
Console.WriteLine($"Tier: {sku.Tier}, Name: {sku.Name}, Size: {sku.Size}, Family: {sku.Family}");
}
}
Available App Service SKUs:
Tier: Free, Name: Free, Size: F1, Family: F
Tier: Basic, Name: Basic1, Size: B1, Family: B
Tier: Standard, Name: Standard1, Size: S1, Family: S
Tier: PremiumV2, Name: PremiumV2_1, Size: P1v2, Family: Pv2
What have I tried?
var skus = await AppServiceExtensions.GetSkusAsync(subscription);
foreach (var sku in skus.Value.Skus)
{
Console.WriteLine($"- Tier: {sku.Tier}, Size: {sku.Size}, Name: {sku.Name}");
}
If you know how to get possible hosting plan configuration. Please do share your knowledge. And if it not currently possible with Azure sdk for .net, I would also appreciate the info.
Thank you and best regards,
Upvotes: 0
Views: 100
Reputation: 43
After my research and further queries, both azure-sdk-for-.net and Azure community teams responded and confirmed that there is currently no way to get the pricing list information from Azure CLI and azure-sdk-for-.net.
Here are the links to the posts:
https://github.com/Azure/azure-sdk-for-net/issues/47644
I will update this answer with any new findings or responses from the Microsoft-Azure teams.
Upvotes: 0
Reputation: 7367
I am able to get the App Service Plan Configurations with the below code.
Tenant
and Subscription ID
to make sure the request is issued for correct Azure AD.using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.AppService;
class Program
{
static async Task Main(string[] args)
{
string TId = "**********";
string SubID = "**********";
var cred = new DefaultAzureCredential(new DefaultAzureCredentialOptions
{
TenantId = TId
});
var ARMC = new ArmClient(cred);
var sub = ARMC.GetSubscriptionResource(new ResourceIdentifier($"/subscriptions/{SubID}"));
Console.WriteLine("App Service Plan Details:");
await foreach (var asp in sub.GetAppServicePlansAsync())
{
Console.WriteLine($"Name: {asp.Data.Name}");
Console.WriteLine($"Tier: {asp.Data.Sku.Tier}, Name: {asp.Data.Sku.Name}, Size: {asp.Data.Sku.Size}, Family: {asp.Data.Sku.Family}");
Console.WriteLine(new string('-', 50));
}
}
}
My .csproj
file:
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Azure.ResourceManager.AppService" Version="1.3.0" />
Output:
As an alternative option you can use Azure CLI to get the details. Refer this SOThread once.
Upvotes: 0