admin管理员组文章数量:1122846
I want to automate the process of listing all policies in Azure that support Customer-managed keys for Azure Storage encryption.
Right now my current approach is to search for them in the Azure portal directly. I want to automate this process to check on this status frequently. Some quick approaches I see are to use either PowerShell or C# and the ArmClient API to query the policyDefinitions
based on a string match. This string match does not account for edge cases like if the acronym "CMK" is used or if the text of the description changes potentially under different languages.
Wondering if there is a more scalable approach or any alternatives that anyone can share?
PowerShell potential option:
Get-AzPolicyDefinition | Where-Object { $_.Properties.Description -like "*customer managed keys*"}
Potential endpoint I can call from an API:
"/providers/Microsoft.Authorization/policyDefinitions?$filter=properties/description+contains+'customer+managed+keys'"
I want to automate the process of listing all policies in Azure that support Customer-managed keys for Azure Storage encryption.
Right now my current approach is to search for them in the Azure portal directly. I want to automate this process to check on this status frequently. Some quick approaches I see are to use either PowerShell or C# and the ArmClient API to query the policyDefinitions
based on a string match. This string match does not account for edge cases like if the acronym "CMK" is used or if the text of the description changes potentially under different languages.
Wondering if there is a more scalable approach or any alternatives that anyone can share?
PowerShell potential option:
Get-AzPolicyDefinition | Where-Object { $_.Properties.Description -like "*customer managed keys*"}
Potential endpoint I can call from an API:
"/providers/Microsoft.Authorization/policyDefinitions?$filter=properties/description+contains+'customer+managed+keys'"
Share
Improve this question
asked Nov 21, 2024 at 19:49
greggreg
1,1982 gold badges24 silver badges51 bronze badges
1 Answer
Reset to default 1The command you are using is not valid for fetching the definitions with descriptions that match the given text."
The Description
property is not under the Properties
section, so it can be called directly.
When I use the same script, it does not fetch any definitions
Output:
You can use the below cmdlet to fetch the Azure policy definitions where the description matches the text customer managed keys, regardless of its position in the text.
Get-AzPolicyDefinition | Where-Object { $_.Description -like "*customer managed keys*" } | Format-List
After running the command, Policy definitions with the description text 'customer managed keys' are displayed.
Output:
本文标签:
版权声明:本文标题:Get all Azure policy definitions related to customer managed keys using PowerShell or ArmClient - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307569a1933357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论