fix: Update MG location parameter name (#1228)

This commit is contained in:
Robert Lightner 2023-02-28 02:14:00 -07:00 коммит произвёл GitHub
Родитель e950255f7e
Коммит 6018ea2e0d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -243,7 +243,7 @@ For this scenario we will use the ALZ custom initiative _Deploy Diagnostic Setti
if ($policyDefId -match '(\/\w+\/\w+\.\w+\/\w+\/)(\w+)(\/.+)') {
$policyDefinitionName = $policyDefId.substring($policyDefId.lastindexof('/') + 1)
$policyDefinitionPath = "./$($policyDefinitionName).json"
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Azure/Enterprise-Scale/main/src/resources/Microsoft.Authorization/policyDefinitions/$($policyDefinitionName).json" -OutFile $policyDefinitionPath
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Azure/Enterprise-Scale/main/src/resources/Microsoft.Authorization/policyDefinitions/$($policyDefinitionName).json" -OutFile $policySetDefinitionPath
$policyDef = Get-Content $policyDefinitionPath | ConvertFrom-Json -Depth 100
$policyName = $policyDef.name
$displayName = $policyDef.properties.displayName
@ -253,7 +253,7 @@ For this scenario we will use the ALZ custom initiative _Deploy Diagnostic Setti
$parameters = $policyDef.properties.parameters | ConvertTo-Json -Depth 100
$policyRule = $policyDef.properties.policyRule | ConvertTo-Json -Depth 100
$policyRule = $policyRule.Replace('[[', '[')
New-AzPolicyDefinition -Name $policyName -DisplayName $displayname -Description $description -Policy $policyRule -Mode $mode -Metadata $metadata -Parameter $parameters -ManagementGroupName $policyDefinitionLocation
New-AzPolicyDefinition -Name $policyName -DisplayName $displayname -Description $description -Policy $policyRule -Mode $mode -Metadata $metadata -Parameter $parameters -ManagementGroupName $policySetDefinitionLocation
}
}
}
@ -266,8 +266,8 @@ For this scenario we will use the ALZ custom initiative _Deploy Diagnostic Setti
$parameters = $policySetDef.properties.parameters | ConvertTo-Json -Depth 100
$policyDefinitions = ConvertTo-Json -InputObject @($policySetDef.properties.policyDefinitions) -Depth 100
$policyDefinitions = $policyDefinitions.Replace('[[', '[')
$policyDefinitions = $policyDefinitions -replace '(\/\w+\/\w+\.\w+\/\w+\/)(\w+)(\/.+)', "`${1}$policyDefinitionLocation`${3}"
New-AzPolicySetDefinition -Name $policyName -DisplayName $displayname -Description $description -PolicyDefinition $policyDefinitions -Metadata $metadata -Parameter $parameters -ManagementGroupName $policyDefinitionLocation
$policyDefinitions = $policyDefinitions -replace '(\/\w+\/\w+\.\w+\/\w+\/)(\w+)(\/.+)', "`${1}$policySetDefinitionLocation`${3}"
New-AzPolicySetDefinition -Name $policyName -DisplayName $displayname -Description $description -PolicyDefinition $policyDefinitions -Metadata $metadata -Parameter $parameters -ManagementGroupName $policySetDefinitionLocation
```
> Note that if you decide on another approach from the script above, there are a number of double square brackets ('[[') in the file. These need to be replaced with single square brackets before the policy set definition is valid syntax.