计算的 FinOps 最佳做法

本文概述了一系列经过验证的计算服务的 FinOps 实践。 它提供有关优化成本、提高效率和深入了解 Azure 中的计算资源的指南。 这些做法根据计算服务类型(例如虚拟机(VM)、Azure Kubernetes 服务(AKS)和 Azure Functions 进行分类。


Azure Kubernetes 服务

以下部分提供 AKS 群集的 Azure Resource Graph (ARG) 查询。 该查询可帮助你深入了解 VM。

查询 - AKS 群集

此 ARG 查询检索有关 Azure 环境中的 AKS 群集的详细信息。

类别

资源管理

查询

resources
| where type == "microsoft.containerservice/managedclusters"
| extend AgentPoolProfiles = properties.agentPoolProfiles
| mvexpand AgentPoolProfiles
| project
    id,
    ProfileName = tostring(AgentPoolProfiles.name),
    Sku = tostring(sku.name),
    Tier = tostring(sku.tier),
    mode = AgentPoolProfiles.mode,
    AutoScaleEnabled = AgentPoolProfiles.enableAutoScaling,
    SpotVM = AgentPoolProfiles.scaleSetPriority,
    VMSize = tostring(AgentPoolProfiles.vmSize),
    nodeCount = tostring(AgentPoolProfiles.['count']),
    minCount = tostring(AgentPoolProfiles.minCount),
    maxCount = tostring(AgentPoolProfiles.maxCount),
    location,
    resourceGroup,
    subscriptionId,
    AKSname = name

虚拟机

以下部分为 VM 提供 ARG 查询。 这些查询可帮助你优化成本、提高效率并深入了解 VM。

查询 - 列出已停止的虚拟机(未解除分配)

此 ARG 查询标识没有 deallocatedrunning 状态的 VM。 它检索有关其电源状态、位置、资源组和订阅 ID 的详细信息。

类别

浪费减少

查询

resources
| where type =~ 'microsoft.compute/virtualmachines' 
    and tostring(properties.extended.instanceView.powerState.displayStatus) != 'VM deallocated' 
    and tostring(properties.extended.instanceView.powerState.displayStatus) != 'VM running'
| extend PowerState = tostring(properties.extended.instanceView.powerState.displayStatus)
| extend VMLocation = location
| extend resourceGroup = strcat('/subscriptions/', subscriptionId, '/resourceGroups/', resourceGroup)
| order by id asc
| project id, PowerState, VMLocation, resourceGroup, subscriptionId

查询 - 虚拟机规模集详细信息

此查询根据其 SKU、现成 VM 优先级和优先级混合策略分析 Azure 环境中的虚拟机规模集。 它提供了成本优化和资源管理策略的见解。

类别

资源管理

查询

resources
| where type =~ 'microsoft.compute/virtualmachinescalesets'
| extend SpotVMs = tostring(properties.virtualMachineProfile.priority)
| extend SpotPriorityMix = tostring(properties.priorityMixPolicy)
| extend SKU = tostring(sku.name)
| extend resourceGroup = strcat('/subscriptions/', subscriptionId, '/resourceGroups/', resourceGroup)
| project id, SKU, SpotVMs, SpotPriorityMix, subscriptionId, resourceGroup, location

查询 - 虚拟机处理器类型分析

此查询标识 Azure 环境中的 VM 使用的处理器类型(ARM、AMD 或 Intel)。 它有助于了解跨不同处理器体系结构分布 VM,这有助于优化工作负荷性能和成本效益。

类别

资源管理

查询

resources
| where type == 'microsoft.compute/virtualmachines'
| extend vmSize = properties.hardwareProfile.vmSize
| extend processorType = case(
    // ARM Processors
    vmSize has "Epsv5"
        or vmSize has "Epdsv5"
        or vmSize has "Dpsv5"
        or vmSize has "Dpdsv", "ARM",
    // AMD Processors
    vmSize has "Standard_D2a"
        or vmSize has "Standard_D4a"
        or vmSize has "Standard_D8a"
        or vmSize has "Standard_D16a"
        or vmSize has "Standard_D32a"
        or vmSize has "Standard_D48a"
        or vmSize has "Standard_D64a"
        or vmSize has "Standard_D96a"
        or vmSize has "Standard_D2as"
        or vmSize has "Standard_D4as"
        or vmSize has "Standard_D8as"
        or vmSize has "Standard_D16as"
        or vmSize has "Standard_D32as"
        or vmSize has "Standard_D48as"
        or vmSize has "Standard_D64as"
        or vmSize has "Standard_D96as", "AMD",
    "Intel"
)
| project vmName = name, processorType, vmSize, resourceGroup

正在查找更多内容?

我们错过了什么吗? 是否希望看到添加的内容? 我们非常想了解你希望在此处介绍的任何问题、问题或解决方案。 创建一个新问题 ,其中包含要在此处查看的详细信息。


相关资源:

相关产品:

相关解决方案: