|
2 | 2 | title: Azure Event Hubs Firewall Rules | Microsoft Docs
|
3 | 3 | description: Use Firewall Rules to allow connections from specific IP addresses to Azure Event Hubs.
|
4 | 4 | ms.topic: article
|
5 |
| -ms.date: 10/28/2021 |
| 5 | +ms.date: 02/23/2022 |
6 | 6 | ---
|
7 | 7 |
|
8 | 8 | # Allow access to Azure Event Hubs namespaces from specific IP addresses or ranges
|
@@ -63,75 +63,94 @@ The following Resource Manager template enables adding an IP filter rule to an e
|
63 | 63 |
|
64 | 64 | **ipMask** in the template is a single IPv4 address or a block of IP addresses in CIDR notation. For example, in CIDR notation 70.37.104.0/24 represents the 256 IPv4 addresses from 70.37.104.0 to 70.37.104.255, with 24 indicating the number of significant prefix bits for the range.
|
65 | 65 |
|
66 |
| -When adding virtual network or firewalls rules, set the value of `defaultAction` to `Deny`. |
| 66 | +> [!NOTE] |
| 67 | +> The default value of the `defaultAction` is `Allow`. When adding virtual network or firewalls rules, make sure you set the `defaultAction` to `Deny`. |
67 | 68 |
|
68 | 69 | ```json
|
69 | 70 | {
|
70 |
| - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", |
| 71 | + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
71 | 72 | "contentVersion": "1.0.0.0",
|
72 | 73 | "parameters": {
|
73 |
| - "eventhubNamespaceName": { |
74 |
| - "type": "string", |
75 |
| - "metadata": { |
76 |
| - "description": "Name of the Event Hubs namespace" |
| 74 | + "eventhubNamespaceName": { |
| 75 | + "type": "String" |
77 | 76 | }
|
78 |
| - }, |
79 |
| - "location": { |
80 |
| - "type": "string", |
81 |
| - "metadata": { |
82 |
| - "description": "Location for Namespace" |
83 |
| - } |
84 |
| - } |
85 |
| - }, |
86 |
| - "variables": { |
87 |
| - "namespaceNetworkRuleSetName": "[concat(parameters('eventhubNamespaceName'), concat('/', 'default'))]", |
88 | 77 | },
|
89 | 78 | "resources": [
|
90 |
| - { |
91 |
| - "apiVersion": "2018-01-01-preview", |
92 |
| - "name": "[parameters('eventhubNamespaceName')]", |
93 |
| - "type": "Microsoft.EventHub/namespaces", |
94 |
| - "location": "[parameters('location')]", |
95 |
| - "sku": { |
96 |
| - "name": "Standard", |
97 |
| - "tier": "Standard" |
98 |
| - }, |
99 |
| - "properties": { } |
100 |
| - }, |
101 |
| - { |
102 |
| - "apiVersion": "2018-01-01-preview", |
103 |
| - "name": "[variables('namespaceNetworkRuleSetName')]", |
104 |
| - "type": "Microsoft.EventHub/namespaces/networkrulesets", |
105 |
| - "dependsOn": [ |
106 |
| - "[concat('Microsoft.EventHub/namespaces/', parameters('eventhubNamespaceName'))]" |
107 |
| - ], |
108 |
| - "properties": { |
109 |
| - "virtualNetworkRules": [<YOUR EXISTING VIRTUAL NETWORK RULES>], |
110 |
| - "ipRules": |
111 |
| - [ |
112 |
| - { |
113 |
| - "ipMask":"10.1.1.1", |
114 |
| - "action":"Allow" |
| 79 | + { |
| 80 | + "type": "Microsoft.EventHub/namespaces", |
| 81 | + "apiVersion": "2021-11-01", |
| 82 | + "name": "[parameters('eventhubNamespaceName')]", |
| 83 | + "location": "East US", |
| 84 | + "sku": { |
| 85 | + "name": "Standard", |
| 86 | + "tier": "Standard", |
| 87 | + "capacity": 1 |
115 | 88 | },
|
116 |
| - { |
117 |
| - "ipMask":"11.0.0.0/24", |
118 |
| - "action":"Allow" |
| 89 | + "properties": { |
| 90 | + "disableLocalAuth": false, |
| 91 | + "zoneRedundant": true, |
| 92 | + "isAutoInflateEnabled": false, |
| 93 | + "maximumThroughputUnits": 0, |
| 94 | + "kafkaEnabled": true |
| 95 | + } |
| 96 | + }, |
| 97 | + { |
| 98 | + "type": "Microsoft.EventHub/namespaces/networkRuleSets", |
| 99 | + "apiVersion": "2021-11-01", |
| 100 | + "name": "[concat(parameters('eventhubNamespaceName'), '/default')]", |
| 101 | + "location": "East US", |
| 102 | + "dependsOn": [ |
| 103 | + "[resourceId('Microsoft.EventHub/namespaces', parameters('eventhubNamespaceName'))]" |
| 104 | + ], |
| 105 | + "properties": { |
| 106 | + "publicNetworkAccess": "Enabled", |
| 107 | + "defaultAction": "Deny", |
| 108 | + "virtualNetworkRules": [], |
| 109 | + "ipRules": [ |
| 110 | + { |
| 111 | + "ipMask":"10.1.1.1", |
| 112 | + "action":"Allow" |
| 113 | + }, |
| 114 | + { |
| 115 | + "ipMask":"11.0.0.0/24", |
| 116 | + "action":"Allow" |
| 117 | + } |
| 118 | + ] |
119 | 119 | }
|
120 |
| - ], |
121 |
| - "trustedServiceAccessEnabled": false, |
122 |
| - "defaultAction": "Deny" |
123 | 120 | }
|
124 |
| - } |
125 |
| - ], |
126 |
| - "outputs": { } |
127 |
| - } |
| 121 | + ] |
| 122 | +} |
| 123 | + |
128 | 124 | ```
|
129 | 125 |
|
130 | 126 | To deploy the template, follow the instructions for [Azure Resource Manager][lnk-deploy].
|
131 | 127 |
|
132 | 128 | > [!IMPORTANT]
|
133 | 129 | > If there are no IP and virtual network rules, all the traffic flows into the namespace even if you set the `defaultAction` to `deny`. The namespace can be accessed over the public internet (using the access key). Specify at least one IP rule or virtual network rule for the namespace to allow traffic only from the specified IP addresses or subnet of a virtual network.
|
134 | 130 |
|
| 131 | +## default action and public network access |
| 132 | + |
| 133 | +### REST API |
| 134 | + |
| 135 | +The default value of the `defaultAction` property was `Deny` for API version **2021-01-01-preview and earlier**. However, the deny rule isn't enforced unless you set IP filters or virtual network (VNet) rules. That is, if you didn't have any IP filters or VNet rules, it's treated as `Allow`. |
| 136 | + |
| 137 | +From API version **2021-06-01-preview onwards**, the default value of the `defaultAction` property is `Allow`, to accurately reflect the service-side enforcement. If the default action is set to `Deny`, IP filters and VNet rules are enforced. If the default action is set to `Allow`, IP filters and VNet rules aren't enforced. The service remembers the rules when you turn them off and then back on again. |
| 138 | + |
| 139 | +The API version **2021-06-01-preview onwards** also introduces a new property named `publicNetworkAccess`. If it's set to `Disabled`, operations are restricted to private links only. If it's set to `Enabled`, operations are allowed over the public internet. |
| 140 | + |
| 141 | +For more information about these properties, see [Create or Update Network Rule Set](/rest/api/eventhub/preview/namespaces-network-rule-set/create-or-update-network-rule-set) and [Create or Update Private Endpoint Connections](/rest/api/eventhub/preview/private-endpoint-connections/create-or-update). |
| 142 | + |
| 143 | +> [!NOTE] |
| 144 | +> None of the above settings bypass validation of claims via SAS or Azure AD authentication. The authentication check always runs after the service validates the network checks that are configured by `defaultAction`, `publicNetworkAccess`, `privateEndpointConnections` settings. |
| 145 | +
|
| 146 | +### Azure portal |
| 147 | + |
| 148 | +Azure portal always uses the latest API version to get and set properties. If you had previously configured your namespace using **2021-01-01-preview and earlier** with `defaultAction` set to `Deny`, and specified zero IP filters and VNet rules, the portal would have previously checked **Selected Networks** on the **Networking** page of your namespace. Now, it checks the **All networks** option. |
| 149 | + |
| 150 | +:::image type="content" source="./media/event-hubs-firewall/firewall-all-networks-selected.png" lightbox="./media/event-hubs-firewall/firewall-all-networks-selected.png" alt-text="Screenshot that shows the Public access page with the All networks option selected."::: |
| 151 | + |
| 152 | + |
| 153 | + |
135 | 154 | ## Next steps
|
136 | 155 |
|
137 | 156 | For constraining access to Event Hubs to Azure virtual networks, see the following link:
|
|
0 commit comments