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
Add a comment  | 

1 Answer 1

Reset to default 1

The 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:

本文标签: