簡體   English   中英

具有多個動態標記篩選器的 Azure 資源管理器查詢

[英]Azure Resource Manager Query with multiple dynamic tag filters

我正在嘗試查詢 Azure 成本管理 API,我希望能夠根據 2 種不同類型的資源標簽過濾結果,但我無法確定格式。 我可以讓單個標簽過濾器正常工作,但我對多個標簽的格式一無所知。 任何人都可以投入他們的 2 美分嗎?

工作單個過濾器查詢:

{
    "type": "Usage",
    "timeframe": "{TimeFrame}",
    "dataset": {
        "granularity": "None",
        "filter": {
            "tags": {
                    "name": "Environment",
                    "operator": "In",
                    "values": [
                        {Environment}
                    ]
                }
        },
        "aggregation": {
            "totalCost": {
                "name": "PreTaxCost",
                "function": "Sum"
            }
        },
        "grouping": [
            {
                "type": "Dimension",
                "name": "{Aggregation}"
            }
        ]
    }
}

我嘗試添加多個過濾器:

{
    "type": "Usage",
    "timeframe": "{TimeFrame}",
    "dataset": {
        "granularity": "None",
        "filter": {
            "tags": [
                {
                    "name": "Environment",
                    "operator": "In",
                    "values": [
                        {Environment}
                    ]
                },
                {
                    "name": "Location",
                    "operator": "In",
                    "values": [
                        {Location}
                    ]
                }
            ]
        },
        "aggregation": {
            "totalCost": {
                "name": "PreTaxCost",
                "function": "Sum"
            }
        },
        "grouping": [
            {
                "type": "Dimension",
                "name": "{Aggregation}"
            }
        ]
    }
}

我對 Azure 很陌生,所以請不要把我烤得太厲害,哈哈。

感謝所有看過我問題的人,即使您沒有我的答案,也非常感謝。

我的參數設置方式存在問題,導致查詢錯誤。 這是具有用於過濾的多個標簽屬性的工作代碼:

{
"type": "Usage",
"timeframe": "{TimeFrame}",
"dataset": {
    "granularity": "None",
    "filter": {
        "and": [
            {
                "tags": {
                    "name": "Location",
                    "operator": "In",
                    "values": [{LocationTag}]
                }
            },
            {
                "tags": {
                    "name": "Environment",
                    "operator": "In",
                    "Values": [{EnvironmentTag}]
                }
            },
            {
                "tags": {
                    "name": "Integrated-System",
                    "operator": "In",
                    "Values": [{IntegratedSystemTag}]
                }
            }
        ]
    },
    "aggregation": {
        "totalCost": {
            "name": "PreTaxCost",
            "function": "Sum"
        }
    },
    "grouping": [
        {
            "type": "Dimension",
            "name": "{Aggregation}"
        }
    ]
}

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM