【问题标题】:Azure Policy ARM template - wildcard in resource nameAzure Policy ARM 模板 - 资源名称中的通配符
【发布时间】:2021-11-08 21:21:29
【问题描述】:

我正在构建一个需要根据名称排除特定资源组的策略分配。应排除以“Atlanta”开头的资源组。 一个数组是不够的。是否可以使用通配符“Atlanta*”创建参数或变量,或者我该如何实现?

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: arrays json azure azure-resource-manager policy


【解决方案1】:

我不知道在门户中执行此操作的方法。我认为您最好的选择虽然不理想,但使用 PowerShell/CLI 以编程方式将此策略分配给您希望的 RG。 PowerShell/CLI 中的逻辑可以排除“亚特兰大”RG。

# Get a reference to the resource group that is the scope of the assignment
$rg = Get-AzResourceGroup -Name '<resourceGroupName>'

# Get a reference to the built-in policy definition to assign
$definition = Get-AzPolicyDefinition | Where-Object { $_.Properties.DisplayName -eq 'Audit VMs that do not use managed disks' }

# Create the policy assignment with the built-in definition against your resource group
New-AzPolicyAssignment -Name 'audit-vm-manageddisks' -DisplayName 'Audit VMs without managed disks Assignment' -Scope $rg.ResourceId -PolicyDefinition $definition

https://docs.microsoft.com/en-us/azure/governance/policy/assign-policy-powershell

【讨论】:

  • 我最终在自定义策略定义中排除了 Atlanta*
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-03-28
  • 1970-01-01
  • 1970-01-01
  • 2017-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多