本文概述 Web 服務的已實證 FinOps 做法集合。 其提供將成本優化、提高效率,以及使用 Azure Resource Graph (ARG) 查詢以深入瞭解 Web 資源的策略。 遵循這些做法,您可以確保 Web 服務符合成本效益,並符合貴組織的財務目標。
App Service
下列各節提供 App Service 的 ARG 查詢。 這些查詢可協助您深入瞭解 App Service 資源,並確保這些資源已使用適當的設定進行設定。 藉由分析 Azure Advisor 的 App Service 方案和呈現建議,您可以將 App Service 資源優化,以達到成本效益。
查詢:Web 應用程式狀態
此 ARG 查詢會擷取 Azure 環境中 Web 應用程式的狀態和基本資訊。
類別
監視
查詢
resources
| where type =~ 'Microsoft.Web/sites'
| project
id,
WebAppName = name,
Type = kind,
Status = tostring(properties.state),
WebAppLocation = location,
AppServicePlan = tostring(properties.serverFarmId),
WebAppRG = resourceGroup,
SubscriptionId = subscriptionId
| order by id asc
移除空白的 App Service 方案
建議:移除沒有應用程式或功能的 App Service 方案,以避免不必要的費用。
關於空的 App Service 方案
App Service 計畫定義了你網頁應用程式的運算資源。 付費方案會根據其設定的 SKU 和實例數量收費,不論是否有應用程式託管。 空的方案可能會在開發過程中,或在應用程式於不同方案間移動時逐漸累積。 移除未使用的方案可免除不必要的成本。
識別空的 App Service 計畫
請使用以下 ARG 查詢,找出沒有託管應用程式的 App Service 方案。
resources
| where type =~ 'microsoft.web/serverfarms'
| where toint(properties.numberOfSites) == 0
| where sku.tier !~ 'Free'
| project
ResourceId = tolower(id),
ResourceName = name,
SKUName = tostring(sku.name),
SKUTier = tostring(sku.tier),
Region = location,
ResourceGroupName = resourceGroup,
SubscriptionId = subscriptionId
查詢:App Service 方案詳細數據
此 ARG 查詢會擷取 Azure 環境中 Azure App 服務 方案的詳細資訊。
類別
資源管理
查詢
resources
| where type == "microsoft.web/serverfarms" and sku.tier !~ 'Free'
| project
planId = tolower(tostring(id)),
name,
skuname = tostring(sku.name),
skutier = tostring(sku.tier),
workers = tostring(properties.numberOfWorkers),
maxworkers = tostring(properties.maximumNumberOfWorkers),
webRG = resourceGroup,
Sites = tostring(properties.numberOfSites),
SubscriptionId = subscriptionId
| join kind=leftouter (
resources
| where type == "microsoft.insights/autoscalesettings"
| project
planId = tolower(tostring(properties.targetResourceUri)),
PredictiveAutoscale = properties.predictiveAutoscalePolicy.scaleMode,
AutoScaleProfiles = properties.profiles,
resourceGroup
) on planId
提供意見反應
請寫下您的快速評價,讓我們知道我們的表現如何。 我們會使用這些評論來改善及擴充 FinOps 工具和資源。
如果您要尋找特定專案,請投票給現有專案或建立新想法。 與其他人分享想法,以獲得更多的選票。 我們專注於擁有最多選票的想法。
相關內容
相關資源:
相關解決方案: