Last active
March 10, 2019 07:38
-
-
Save kasunkv/981c2a6ceaf8b6dcd2a48b2a6cc0d7e7 to your computer and use it in GitHub Desktop.
Creating a Policy Assignment using Azure CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login to Azure | |
az login --use-device-code | |
# Get Regerence to Resource Group | |
$rgId = az group show --name "az-policy-rg" --query "id" --output tsv | |
# Get Reference to the Azure Policy Definition | |
$policyName = az policy definition list --query "[?displayName == 'Audit use of classic virtual machines'].name" --output tsv | |
# Assign the policy | |
az policy assignment create --name "Check for Classic VMs" --display-name "Check for Classic VMs" --policy $policyName --scope $rgId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment