helper/eval_arm_expression.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
Class EvaluateARMExpression {
    [String] $expression
 
    EvaluateARMExpression($expression) {
         
        if ($expression -match "\w+\([a-zA-Z0-9_(\/)', -.]+") {
            $this.expression = $Matches[0]
        }
        else {
 
        }
    }
 
}
 
[EvaluateARMExpression] "[concat(variables('accountName'), '/', parameters('databaseName'), '/', parameters('graphName'))]"
 
 
 
$template = Get-Content D:\Workspace\Repository\AzViz\networkwatcherrg.json | ConvertFrom-Json
$params = $template.parameters.psobject.Properties.foreach({
    [PSCustomObject]@{
        name = $_.name
        type = $_.Value.type
        default = $_.Value.defaultValue
    }
     
})
 
$vars = $template.variables.psobject.Properties.foreach({
    [PSCustomObject]@{
        name = $_.name
        type = $_.Value.type
        default = $_.Value.defaultValue
    }
     
})
 
function eval($string){
    $arg = if($string -match "'\w+'"){$Matches.Values -replace "'",""}
 
    if($arg){
        $params.where({$_.name -eq $arg}).name
    }
}
 
#>