Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure/Terraform-azurerm\u监视器\u自动缩放\u存储队列设置_Azure_Terraform_Terraform Provider Azure_Azure Storage Queues - Fatal编程技术网

Azure/Terraform-azurerm\u监视器\u自动缩放\u存储队列设置

Azure/Terraform-azurerm\u监视器\u自动缩放\u存储队列设置,azure,terraform,terraform-provider-azure,azure-storage-queues,Azure,Terraform,Terraform Provider Azure,Azure Storage Queues,我想创建一个规则,以便在队列中的消息数大于某个值时缩放应用程序服务计划 队列定义如下所示: resource "azurerm_storage_queue" "myqueue" { name = "myqueue" storage_account_name = "storageaccountname" } rule { metric_trigger {

我想创建一个规则,以便在队列中的消息数大于某个值时缩放应用程序服务计划

队列定义如下所示:

resource "azurerm_storage_queue" "myqueue" {
  name                 = "myqueue"
  storage_account_name = "storageaccountname"
}
    rule {
      metric_trigger {
        metric_name        = "ApproximateMessageCount"
        metric_resource_id = azurerm_storage_queue.myqueue.id
        time_grain         = "PT1M"
        statistic          = "Average"
        time_window        = "PT1M"
        time_aggregation   = "Average"
        operator           = "GreaterThanOrEqual"
        threshold          = 100
      }

      scale_action {
        direction = "Increase"
        type      = "ChangeCount"
        value     = "1"
        cooldown  = "PT10M"
      }
    }
缩放规则如下所示:

resource "azurerm_storage_queue" "myqueue" {
  name                 = "myqueue"
  storage_account_name = "storageaccountname"
}
    rule {
      metric_trigger {
        metric_name        = "ApproximateMessageCount"
        metric_resource_id = azurerm_storage_queue.myqueue.id
        time_grain         = "PT1M"
        statistic          = "Average"
        time_window        = "PT1M"
        time_aggregation   = "Average"
        operator           = "GreaterThanOrEqual"
        threshold          = 100
      }

      scale_action {
        direction = "Increase"
        type      = "ChangeCount"
        value     = "1"
        cooldown  = "PT10M"
      }
    }

问题出在
度量\u资源\u id
-我不确定它需要什么属性或id。错误消息是路径段的数量不能被2整除。我认为这是因为队列的id只是它的名称,而它的资源id应该类似于
/subscriptions/xxxxxxx/resourceGroups/xxxxxx/providers/Microsoft.Storage/storageAccounts/storageaccountname/services/queue/queues/myqueue“
但我不确定如何从terraform获取此信息。

azurerm_storage_queue.myqueue.id的输出是一种Url格式
https://storageaccountname.queue.core.windows.net/mysamplequeue

metric\u resource\u id
要求发出度量的资源的资源id。据我所知,我们不能直接从地形资源属性获取资源格式,但我们可以自行构造资源id以

metric_resource_id = join("/",["${azurerm_storage_account.example.id}","services/queue/queues","mysamplequeue"])
比如说,

rule {
  metric_trigger {
    metric_name        = "ApproximateMessageCount"
    metric_resource_id = join("/",["${azurerm_storage_account.example.id}","services/queue/queues","myqueue"])
    time_grain         = "PT1M"
    statistic          = "Average"
    time_window        = "PT5M"
    time_aggregation   = "Average"
    operator           = "GreaterThanOrEqual"
    threshold          = 100
  }

实际上,看起来我可以使用队列的名称。我能够使用这个
“${azurerm\u storage\u account.example.id}/services/queue/queues/${azurerm\u storage\u queue.myqueue.name}”