Microsoft Azure AI Solution Exam AI-102 | Network Traffic Restriction with Azure Policies

Enforce Network Traffic Restrictions using Azure Policies

Question

You are tasked to enforce network traffic restrictions to allow traffic from the private network that you have set up in Azure, an On-Prem subnet or a specific public internet IP range.

To achieve this objective, you plan to use Azure built-in policies.

Review the code snippet given below and select answer choices to complete this code, based on the scenario given above.

(select two options)

 "policyRule": { "if": { "allOf": [ { "field": "type", "equals": "Microsoft.CognitiveServices/accounts" }, { "field": "..............................................................................", "notEquals": "............................................................................." } ] }, "then": { "effect": "[parameters('effect')]" } } 

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answers: D and E

Here is the completed code snippet.

<pre>"policyRule": {

"if": {

"allOf": [

{

"field": "type",

"equals": "Microsoft.CognitiveServices/accounts"

},

{

"field": "Microsoft.CognitiveServices/accounts/networkAcls.defaultAction",

"notEquals": "Deny"

}

]

},

"then": {

"effect": "[parameters('effect')]"

}

}

</pre>Option A is incorrect because this policy restriction will disable access to the public-facing internet IP range.

As per the scenario, a specific public IP range should be allowed to access the network.

Option B is incorrect because the intent is to deny unintended traffic and not to disable access.

Option C is incorrect because private endpoints are purposed to connect your virtual network to Azure services without using a public IP address.

It is not aimed at restructuring access to specific On-Prem subnet or public IP range.

Option D is correct because Network ACLs help achieve this objective.

Option E is correct because the intent is to Deny unintended network traffic.

Reference:

To learn more about Cognitive Services build in policies, use the link given below:

The code snippet provided is a JSON code block that defines a policy rule for an Azure policy. The policy rule is designed to restrict network traffic for Microsoft Cognitive Services accounts based on specific conditions.

The "if" section of the policy rule defines the conditions that must be met for the policy to be enforced. In this case, there are two conditions that must both be true for the policy to be applied:

  1. The "type" field must be equal to "Microsoft.CognitiveServices/accounts". This ensures that the policy only applies to Cognitive Services accounts.

  2. The "field" field must not be equal to a specific value. This is where we need to select the correct option to complete the policy rule.

Option A: Microsoft.CognitiveServices/accounts/publicNetworkAccess This option is a valid field for Cognitive Services accounts, but it does not match the scenario given in the question. This option refers to the public network access setting for the account, which is not related to the specified network traffic restrictions.

Option B: Disabled This option is not a valid field for Cognitive Services accounts and therefore cannot be used to complete the policy rule.

Option C: Microsoft.CognitiveServices/accounts/privateEndpointConnections[*] This option is a valid field for Cognitive Services accounts and matches the scenario given in the question. This field refers to the private endpoint connections for the account, which can be used to restrict network traffic to specific subnets or IP ranges.

Option D: Microsoft.CognitiveServices/accounts/networkAcls.defaultAction This option is a valid field for Cognitive Services accounts, but it does not match the scenario given in the question. This field refers to the default action for the network access control list (ACL) for the account, which is not related to the specified network traffic restrictions.

Option E: Deny This option is not a valid field for Cognitive Services accounts and therefore cannot be used to complete the policy rule.

The "then" section of the policy rule defines the action to take when the conditions in the "if" section are met. In this case, the action is specified by the "effect" field, which is defined by a parameter called "effect". The value of the "effect" parameter is determined outside of the policy rule and specifies whether to allow or deny network traffic based on the conditions in the "if" section.

In summary, the correct options to complete the policy rule are:

  • Option C: Microsoft.CognitiveServices/accounts/privateEndpointConnections[*]
  • Option D: Microsoft.CognitiveServices/accounts/networkAcls.defaultAction

The complete policy rule would look something like this:

json
"policyRule": { "if": { "allOf": [ { "field": "type", "equals": "Microsoft.CognitiveServices/accounts" }, { "field": "Microsoft.CognitiveServices/accounts/privateEndpointConnections[*]", "notEquals": "..." } ] }, "then": { "effect": "[parameters('effect')]" } }