0
0
Azurecloud~10 mins

Policy assignments and compliance in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign a policy to a resource group.

Azure
az policy assignment create --name MyPolicyAssignment --policy [1] --resource-group MyResourceGroup
Drag options to blanks, or click blank then click option'
ApolicyDefinitionId
BpolicyDefinitionName
CpolicyDefinition
DpolicyAssignmentId
Attempts:
3 left
💡 Hint
Common Mistakes
Using the policy assignment ID instead of the policy definition name.
Using an incorrect parameter name.
2fill in blank
medium

Complete the code to check compliance state for a policy assignment.

Azure
az policy state summarize --management-group [1]
Drag options to blanks, or click blank then click option'
ApolicyAssignment
Bsubscription
CresourceGroup
DmanagementGroup
Attempts:
3 left
💡 Hint
Common Mistakes
Using subscription or resource group instead of management group.
Confusing policy assignment with management group.
3fill in blank
hard

Fix the error in the command to assign a policy with parameters.

Azure
az policy assignment create --name EnforceTag --policy [1] --params '{"tagName": {"value": "environment"}}' --scope /subscriptions/12345/resourceGroups/MyRG
Drag options to blanks, or click blank then click option'
A/subscriptions/12345/providers/Microsoft.Authorization/policyDefinitions/EnforceTagPolicy
BpolicyDefinitionName
CpolicyDefinition
DpolicyDefinitionReferenceId
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the policy name instead of the full ID.
Incorrect JSON format in parameters.
4fill in blank
hard

Fill both blanks to create a policy assignment with a description and enforcement mode.

Azure
az policy assignment create --name AuditVMs --policy [1] --description "[2]"
Drag options to blanks, or click blank then click option'
A/subscriptions/12345/providers/Microsoft.Authorization/policyDefinitions/audit-vms
BAudit all virtual machines
CEnforce
DAudit
Attempts:
3 left
💡 Hint
Common Mistakes
Using enforcement mode instead of description text.
Using policy name instead of full ID.
5fill in blank
hard

Fill all three blanks to list policy compliance states filtered by resource group and policy assignment.

Azure
az policy state list --resource-group [1] --policy-assignment [2] --filter "complianceState eq '[3]'"
Drag options to blanks, or click blank then click option'
AMyResourceGroup
BEnforceTagAssignment
CNonCompliant
DCompliant
Attempts:
3 left
💡 Hint
Common Mistakes
Using subscription name instead of resource group.
Filtering for 'Compliant' instead of 'NonCompliant'.