簡體   English   中英

Azure 資源和資源組的工作簿參數

[英]Azure Workbook parameter for resource and resource group

在我認為是一個簡單查詢的問題上,我被 Kusto 打敗了……我正在制作我的第一個工作簿並使用參數。 I can list and select a Resource Group, but I can't make the following parameter (Virtual Machines) populate with the VMs when more than one Resource Group is selected. ResourceGroup傳遞一個逗號分隔的組名稱字符串作為屬性resourcegroup組就好了。 我無法弄清楚如何將該字符串轉換為可用的 where-statement。 當我手動將多個資源組串在一起時,我的查詢工作得很好,所以我假設我對 Kusto 中的let和 arrays 的理解讓我感到焦頭爛額。 如果有更好的方法來做我想做的事情,請告訴我。

//This will work so long as 1 Resource Group is passed from the previous parameter
resources
| where resourceGroup in ('{ResourceGroup:resourcegroup}') and type =~ microsoft.compute/virtualmachines'
| project value = id , label = name

我發現我可以使用split('{ResourceGroup:resourcegroup}',",")獲得一個合適的數組,但是,我還是無法將 object 與 where 語句結合起來。

任何幫助深表感謝!

https://github.com/microsoft/Application-Insights-Workbooks/blob/master/Documentation/Parameters/DropDown.md#special-casing-all

通常有一種方法可以做到這一點:

let resourceGroups = dynamic([{ResourceGroup:resourcegroup}]);// turns even an empty string into a valid array

resources
| where (array_length(resourceGroups)==0 // allows 0 length array to be "all"
or resourceGroup in (resourceGroups)) // or filters to only those in the set
 and type =~ microsoft.compute/virtualmachines'
| project value = id , label = name

但是,我認為 Azure Resource Graph 不允許這樣使用let嗎?

如果你得到一個let isn't allowed 的錯誤,你將不得不做幾次內聯的動態事情:

resources
| where (array_length(dynamic([{ResourceGroup:resourcegroup}]))==0 // allows 0 length array to be "all"
or resourceGroup in (dynamic([{ResourceGroup:resourcegroup}]))) // or filters to only those in the set
 and type =~ microsoft.compute/virtualmachines'
| project value = id , label = name

暫無
暫無

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

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