|
| 1 | +--- |
| 2 | +title: Use Azure Policy to audit for compliance of minimum TLS version for an Azure Event Hubs namespace |
| 3 | +titleSuffix: Event Hubs |
| 4 | +description: Configure Azure Policy to audit compliance of Azure Event Hubs for using a minimum version of Transport Layer Security (TLS). |
| 5 | +services: event-hubs |
| 6 | +author: EldertGrootenboer |
| 7 | + |
| 8 | +ms.service: event-hubs |
| 9 | +ms.topic: article |
| 10 | +ms.date: 04/25/2022 |
| 11 | +ms.author: egrootenboer |
| 12 | +--- |
| 13 | + |
| 14 | +# Use Azure Policy to audit for compliance of minimum TLS version for an Azure Event Hubs namespace (Preview) |
| 15 | + |
| 16 | +If you have a large number of Microsoft Azure Event Hubs namespaces, you may want to perform an audit to make sure that all namespaces are configured for the minimum version of TLS that your organization requires. To audit a set of Event Hubs namespaces for their compliance, use Azure Policy. Azure Policy is a service that you can use to create, assign, and manage policies that apply rules to Azure resources. Azure Policy helps you to keep those resources compliant with your corporate standards and service level agreements. For more information, see [Overview of Azure Policy](../governance/policy/overview.md). |
| 17 | + |
| 18 | +## Create a policy with an audit effect |
| 19 | + |
| 20 | +Azure Policy supports effects that determine what happens when a policy rule is evaluated against a resource. The audit effect creates a warning when a resource is not in compliance, but does not stop the request. For more information about effects, see [Understand Azure Policy effects](../governance/policy/concepts/effects.md). |
| 21 | + |
| 22 | +To create a policy with an audit effect for the minimum TLS version with the Azure portal, follow these steps: |
| 23 | + |
| 24 | +1. In the Azure portal, navigate to the Azure Policy service. |
| 25 | +2. Under the **Authoring** section, select **Definitions**. |
| 26 | +3. Select **Add policy definition** to create a new policy definition. |
| 27 | +4. For the **Definition location** field, select the **More** button to specify where the audit policy resource is located. |
| 28 | +5. Specify a name for the policy. You can optionally specify a description and category. |
| 29 | +6. Under **Policy rule** , add the following policy definition to the **policyRule** section. |
| 30 | + |
| 31 | + ```json |
| 32 | + { |
| 33 | + "policyRule": { |
| 34 | + "if": { |
| 35 | + "allOf": [ |
| 36 | + { |
| 37 | + "field": "type", |
| 38 | + "equals": "Microsoft.EventHub/namespaces" |
| 39 | + }, |
| 40 | + { |
| 41 | + "not": { |
| 42 | + "field": " Microsoft.EventHub/namespaces/minimumTlsVersion", |
| 43 | + "equals": "1.2" |
| 44 | + } |
| 45 | + } |
| 46 | + ] |
| 47 | + }, |
| 48 | + "then": { |
| 49 | + "effect": "audit" |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + ``` |
| 54 | + |
| 55 | +7. Save the policy. |
| 56 | + |
| 57 | +### Assign the policy |
| 58 | + |
| 59 | +Next, assign the policy to a resource. The scope of the policy corresponds to that resource and any resources beneath it. For more information on policy assignment, see [Azure Policy assignment structure](../governance/policy/concepts/assignment-structure.md). |
| 60 | + |
| 61 | +To assign the policy with the Azure portal, follow these steps: |
| 62 | + |
| 63 | +1. In the Azure portal, navigate to the Azure Policy service. |
| 64 | +2. Under the **Authoring** section, select **Assignments**. |
| 65 | +3. Select **Assign policy** to create a new policy assignment. |
| 66 | +4. For the **Scope** field, select the scope of the policy assignment. |
| 67 | +5. For the **Policy definition** field, select the **More** button, then select the policy you defined in the previous section from the list. |
| 68 | +6. Provide a name for the policy assignment. The description is optional. |
| 69 | +7. Leave **Policy enforcement** set to _Enabled_. This setting has no effect on the audit policy. |
| 70 | +8. Select **Review + create** to create the assignment. |
| 71 | + |
| 72 | +### View compliance report |
| 73 | + |
| 74 | +After you have assigned the policy, you can view the compliance report. The compliance report for an audit policy provides information on which Event Hubs namespaces are not in compliance with the policy. For more information, see [Get policy compliance data](../governance/policy/how-to/get-compliance-data.md). |
| 75 | + |
| 76 | +It may take several minutes for the compliance report to become available after the policy assignment is created. |
| 77 | + |
| 78 | +To view the compliance report in the Azure portal, follow these steps: |
| 79 | + |
| 80 | +1. In the Azure portal, navigate to the Azure Policy service. |
| 81 | +2. Select **Compliance**. |
| 82 | +3. Filter the results for the name of the policy assignment that you created in the previous step. The report shows how many resources are not in compliance with the policy. |
| 83 | +4. You can drill down into the report for additional details, including a list of Event Hubs namespaces that are not in compliance. |
| 84 | + |
| 85 | +## Use Azure Policy to enforce the minimum TLS version |
| 86 | + |
| 87 | +Azure Policy supports cloud governance by ensuring that Azure resources adhere to requirements and standards. To enforce a minimum TLS version requirement for the Event Hubs namespaces in your organization, you can create a policy that prevents the creation of a new Event Hubs namespace that sets the minimum TLS requirement to an older version of TLS than that which is dictated by the policy. This policy will also prevent all configuration changes to an existing namespace if the minimum TLS version setting for that namespace is not compliant with the policy. |
| 88 | + |
| 89 | +The enforcement policy uses the deny effect to prevent a request that would create or modify an Event Hubs namespace so that the minimum TLS version no longer adheres to your organization's standards. For more information about effects, see [Understand Azure Policy effects](../governance/policy/concepts/effects.md). |
| 90 | + |
| 91 | +To create a policy with a deny effect for a minimum TLS version that is less than TLS 1.2, provide the following JSON in the **policyRule** section of the policy definition: |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "policyRule": { |
| 96 | + "if": { |
| 97 | + "allOf": [ |
| 98 | + { |
| 99 | + "field": "type", |
| 100 | + "equals": " Microsoft.EventHub/namespaces" |
| 101 | + }, |
| 102 | + { |
| 103 | + "not": { |
| 104 | + "field": " Microsoft.EventHub/namespaces/minimumTlsVersion", |
| 105 | + "equals": "1.2" |
| 106 | + } |
| 107 | + } |
| 108 | + ] |
| 109 | + }, |
| 110 | + "then": { |
| 111 | + "effect": "deny" |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +After you create the policy with the deny effect and assign it to a scope, a user cannot create an Event Hubs namespace with a minimum TLS version that is older than 1.2. Nor can a user make any configuration changes to an existing Event Hubs namespace that currently requires a minimum TLS version that is older than 1.2. Attempting to do so results in an error. The required minimum TLS version for the Event Hubs namespace must be set to 1.2 to proceed with namespace creation or configuration. |
| 118 | + |
| 119 | +An error will be shown if you try to create an Event Hubs namespace with the minimum TLS version set to TLS 1.0 when a policy with a deny effect requires that the minimum TLS version be set to TLS 1.2. |
| 120 | + |
| 121 | +## Next steps |
| 122 | + |
| 123 | +See the following documentation for more information. |
| 124 | + |
| 125 | +- [Enforce a minimum required version of Transport Layer Security (TLS) for requests to an Event Hubs namespace](transport-layer-security-enforce-minimum-version.md) |
| 126 | +- [Configure the minimum TLS version for an Event Hubs namespace](transport-layer-security-configure-minimum-version.md) |
| 127 | +- [Configure Transport Layer Security (TLS) for an Event Hubs client application](transport-layer-security-configure-client-version.md) |
0 commit comments