通过 Terraform 的 Azure 应用服务计划自动缩放规则

问题描述 投票:0回答:1

我已使用 terraform 中的 azurerm_monitor_autoscale_setting 资源来创建自动缩放规则以扩展 azure 应用程序服务计划。规则已正确创建,但我找不到将应用程序服务计划从 terraform 代码本身从“自动”切换到“基于规则”的方法。如果我进入门户并将其切换到“基于规则”,它会采用我正确创建的规则,但我需要一种方法来完全通过 terraform 来完成此操作,因为在我的生产环境中我无法进行任何手动更改。

this is how the scale out setting will be even after creating the rules

this is the expected behaviour/result am looking for

这是我正在使用的示例代码片段(只是其中的第一部分):

// autoscaling rules:
resource "azurerm_monitor_autoscale_setting" "autoscaling" {
  name = "${var.azurerm_webapp_service_plan}-autoscale"
  resource_group_name = var.rg_name
  location = var.location
  target_resource_id = var.plan_type == "web_app" ? azurerm_service_plan.webapp_svcplan[0].id : azurerm_service_plan.fa_svcplan[0].id
  
  # Autoscaling Profile: Default
  profile {
    // scaling values for lower envs, change these values for Uat & Prod
    name = "defaultProfile"
    capacity {
      default = 1
      minimum = 1
      maximum = 5
    }

    # Scale out when CPU, Memory, or SocketOutboundAll exceed thresholds
    rule {
      metric_trigger {
        metric_name = "CpuPercentage"
        metric_resource_id = var.plan_type == "web_app" ? azurerm_service_plan.webapp_svcplan[0].id : azurerm_service_plan.fa_svcplan[0].id
        operator = "GreaterThan"
        statistic = "Average"
        threshold = 85
        time_grain = "PT1M"
        time_window = "PT5M"
        time_aggregation = "Average"
      }

and its creating the rules like this, which is correct but i need the app service plan to use this rule by default

azure terraform autoscaling azure-app-service-plans appservice
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.