|
1 | 1 | ---
|
2 |
| -title: Configure role-based access control with Data Access Policy |
3 |
| -description: Learn how to configure role-based access control with Data Access Policy. |
| 2 | +title: Configure custom data access policies |
| 3 | +description: Learn how to create and configure a data access policy for Azure Cache for Redis and enable role-based access control via Microsoft Entra ID. |
4 | 4 | ms.custom: references_regions, ignite-2024
|
5 | 5 |
|
6 | 6 | ms.topic: conceptual
|
7 |
| -ms.date: 06/05/2023 |
| 7 | +ms.date: 04/21/2025 |
8 | 8 | appliesto:
|
9 | 9 | - ✅ Azure Cache for Redis
|
10 | 10 |
|
11 | 11 | ---
|
12 | 12 |
|
13 |
| -# Configure role-based access control with Data Access Policy |
| 13 | +# Configure custom data access policies |
14 | 14 |
|
15 |
| -Managing access to your Azure Cache for Redis instance is critical to ensure that the right users have access to the right set of data and commands. In Redis version 6, the [Access Control List](https://redis.io/docs/management/security/acl/) (ACL) was introduced. ACL limits which user can execute certain commands, and the keys that a user can be access. For example, you can prohibit specific users from deleting keys in the cache using [DEL](https://redis.io/commands/del/) command. |
| 15 | +Managing access to your Azure Redis cache instance is critical to ensuring that the right users have access to the right set of data and commands. Redis version 6 introduced the [Access Control List](https://redis.io/docs/management/security/acl/) (ACL), which lists the keys that specific users can access and the commands that they can execute. For example, you can prohibit specific users from using the [DEL](https://redis.io/commands/del/) command to delete keys in the cache. |
16 | 16 |
|
17 |
| -Azure Cache for Redis now integrates this ACL functionality with Microsoft Entra ID to allow you to configure your Data Access Policies for your application's service principal and managed identity. |
| 17 | +Azure Cache for Redis integrates this ACL functionality with Microsoft Entra to allow you to configure and assign data access policies for your application's users, service principal, and managed identity. Azure Cache for Redis offers three built-in access policies that you can assign via role-based access control (RBAC): **Data Owner**, **Data Contributor**, and **Data Reader**. |
18 | 18 |
|
19 |
| -Azure Cache for Redis offers three built-in access policies: _Data Owner_, _Data Contributor_, and _Data Reader_. If the built-in access policies don't satisfy your data protection and isolation requirements, you can create and use your own custom data access policy as described in [Configure custom data access policy](#configure-a-custom-data-access-policy-for-your-application). |
| 19 | +If the built-in access policies don't satisfy your data protection and isolation requirements, you can create and use your own custom data access policies. This article describes configuring a custom data access policy for Azure Cache for Redis and enabling RBAC via Microsoft Entra authentication. |
20 | 20 |
|
21 | 21 | ## Scope of availability
|
22 | 22 |
|
23 | 23 | | **Tier** | Basic, Standard, Premium | Enterprise, Enterprise Flash |
|
24 | 24 | |:-----------------|:------------------------:|:----------------------------:|
|
25 | 25 | | **Availability** | Yes | No |
|
26 | 26 |
|
27 |
| -## Prerequisites and limitations |
| 27 | +## Limitations |
28 | 28 |
|
29 |
| -- Redis ACL and Data Access Policies aren't supported on Azure Cache for Redis instances that run Redis version 4. |
30 |
| -- Microsoft Entra authentication and authorization are supported for SSL connections only. |
31 |
| -- Some Redis commands are [blocked](cache-configure.md#redis-commands-not-supported-in-azure-cache-for-redis). |
| 29 | +- Configuring data access policies isn't supported on Enterprise and Enterprise Flash tiers. |
| 30 | +- Redis ACL and data access policies aren't supported on Azure Redis instances that run Redis version 4. |
| 31 | +- Microsoft Entra authentication and authorization are supported only for Secure Socket Layer (SSL) connections. |
| 32 | +- Some Redis commands are blocked in Azure Cache for Redis. For more information, see [Redis commands not supported in Azure Cache for Redis](cache-configure.md#redis-commands-not-supported-in-azure-cache-for-redis). |
32 | 33 |
|
33 |
| -## Permissions for your data access policy |
| 34 | +## Redis ACL permissions |
34 | 35 |
|
35 |
| -As documented on [Redis Access Control List](https://redis.io/docs/management/security/acl/), ACL in Redis version 6.0 allows configuring access permissions for three areas: |
| 36 | +[Redis ACL](https://redis.io/docs/management/security/acl/) in Redis version 6.0 allows configuring access permissions for three areas: command categories, commands, and keys. |
36 | 37 |
|
37 | 38 | ### Command categories
|
38 | 39 |
|
39 |
| -Redis has created groupings of commands such as administrative commands, dangerous commands, etc. to make setting permissions on a group of commands easier. |
40 |
| - |
41 |
| -- Use `+@commandcategory` to allow a command category |
42 |
| -- Use `-@commandcategory` to disallow a command category |
43 |
| - |
44 |
| -These [commands](cache-configure.md#redis-commands-not-supported-in-azure-cache-for-redis) are still blocked. The following groups are useful command categories that Redis supports. For more information on command categories, see the full list under the heading [Command Categories](https://redis.io/docs/management/security/acl/). |
45 |
| - |
46 |
| -- `admin` |
47 |
| - - Administrative commands. Normal applications never need to use these, including `MONITOR`, `SHUTDOWN`, and others. |
48 |
| -- `dangerous` |
49 |
| - - Potentially dangerous commands. Each should be considered with care for various reasons, including `FLUSHALL`, `RESTORE`, `SORT`, `KEYS`, `CLIENT`, `DEBUG`, `INFO`, `CONFIG`, and others. |
50 |
| -- `keyspace` |
51 |
| - - Writing or reading from keys, databases, or their metadata in a type agnostic way, including `DEL`, `RESTORE`, `DUMP`, `RENAME`, `EXISTS`, `DBSIZE`, `KEYS`, `EXPIRE`, `TTL`, `FLUSHALL`, and more. Commands that can modify the keyspace, key, or metadata also have the write category. Commands that only read the keyspace, key, or metadata have the read category. |
52 |
| -- `pubsub` |
53 |
| - - PubSub-related commands. |
54 |
| -- `read` |
55 |
| - - Reading from keys, values or metadata. Commands that don't interact with keys, don't have either read or write. |
56 |
| -- `set` |
57 |
| - - Data type: sets related. |
58 |
| -- `sortedset` |
59 |
| - - Data type: sorted sets related. |
60 |
| -- `stream` |
61 |
| - - Data type: streams related. |
62 |
| -- `string` |
63 |
| - - Data type: strings related. |
64 |
| -- `write` |
65 |
| - - Writing to keys (values or metadata). |
| 40 | +Redis created *command categories*, such as administrative commands and dangerous commands, to make setting permissions on a group of commands easier. In a permissions string, use `+@<category>` to allow a command category or `-@<category>` to disallow a command category. |
66 | 41 |
|
67 |
| -### Commands |
68 |
| - |
69 |
| -_Commands_ allow you to control which specific commands can be run by a particular Redis user. |
70 |
| - |
71 |
| -- Use `+command` to allow a command. |
72 |
| -- Use `-command` to disallow a command. |
73 |
| - |
74 |
| -### Keys |
75 |
| - |
76 |
| -Keys allow you to control access to specific keys or groups of keys stored in the cache. |
| 42 | +Redis supports the following useful command categories. For more information and a full list, see the **Command Categories** heading in the [Redis ACL documentation](https://redis.io/docs/management/security/acl/). |
77 | 43 |
|
78 |
| -- Use `~<pattern>` to provide a pattern for keys. |
| 44 | +|Category|Description| |
| 45 | +|--------|-----------| |
| 46 | +|`admin`|Administrative commands, such as `MONITOR` and `SHUTDOWN`. Normal applications never need to use these commands.| |
| 47 | +|`dangerous`|Potentially dangerous commands, including `FLUSHALL`, `RESTORE`, `SORT`, `KEYS`, `CLIENT`, `DEBUG`, `INFO`, and `CONFIG`. Consider each with care, for various reasons.| |
| 48 | +|`keyspace`|Includes `DEL`, `RESTORE`, `DUMP`, `RENAME`, `EXISTS`, `DBSIZE`, `KEYS`, `EXPIRE`, `TTL`, and `FLUSHALL`. Writing or reading from keys, databases, or their metadata in a type agnostic way. Commands that only read the keyspace, key, or metadata have the `read` category. Commands that can modify the keyspace, key, or metadata also have the `write` category.| |
| 49 | +|`pubsub`|PubSub-related commands.| |
| 50 | +|`read`|Reading from keys, values or metadata. Commands that don't interact with keys don't have either `read` or `write`.| |
| 51 | +|`set`|Data type: sets related.| |
| 52 | +|`sortedset`|Data type: sorted sets related.| |
| 53 | +|`stream`|Data type: streams related.| |
| 54 | +|`string`|Data type: strings related.| |
| 55 | +|`write`|Writing values or metadata to keys.| |
79 | 56 |
|
80 |
| -- Use either `~*` or `allkeys` to indicate that the command category permissions apply to all keys in the cache instance. |
| 57 | +>[!NOTE] |
| 58 | +>Commands that are [blocked](cache-configure.md#redis-commands-not-supported-in-azure-cache-for-redis) for Azure Redis remain blocked within the categories. |
81 | 59 |
|
82 |
| -### How to specify permissions |
| 60 | +### Commands |
83 | 61 |
|
84 |
| -To specify permissions, you need to create a string to save as your custom access policy, then assign the string to your Azure Cache for Redis user. |
| 62 | +*Commands* allow you to control which specific commands a particular Redis user can run. In a permissions string, use `+<command>` to allow a command or `-<command>` to disallow a command. |
85 | 63 |
|
86 |
| -The following list contains some examples of permission strings for various scenarios. |
| 64 | +### Keys |
87 | 65 |
|
88 |
| -- Allow application to execute all commands on all keys |
| 66 | +*Keys* allow you to control access to specific keys or groups of keys stored in the cache. Use `~<pattern>` in a permission string to provide a pattern for keys. Use either `~*` or `allkeys` to indicate that the permissions apply to all keys in the cache. |
89 | 67 |
|
90 |
| - Permissions string: `+@all allkeys` |
| 68 | +## Configure a custom data access policy for your application |
91 | 69 |
|
92 |
| -- Allow application to execute only _read_ commands |
| 70 | +To configure a custom data access policy, you create a permissions string to use as your custom access policy, and enable Microsoft Entra authentication for your cache. |
93 | 71 |
|
94 |
| - Permissions string: `+@read ~*` |
| 72 | +### Specify permissions |
95 | 73 |
|
96 |
| -- Allow application to execute _read_ command category and set command on keys with prefix `Az`. |
| 74 | +Configure permission strings according to your requirements. The following examples show permission strings for various scenarios: |
97 | 75 |
|
98 |
| - Permissions string: `+@read +set ~Az*` |
| 76 | +|Permissions string|Description| |
| 77 | +|------------------|-----------| |
| 78 | +|`+@all allkeys`|Allow application to execute all commands on all keys.| |
| 79 | +|`+@read ~*`|Allow application to execute only `read` command category.| |
| 80 | +|`+@read +set ~Az*`|Allow application to execute `read` command category and set command on keys with prefix `Az`.| |
99 | 81 |
|
100 |
| -## Configure a custom data access policy for your application |
| 82 | +### Create the custom data access policy |
101 | 83 |
|
102 |
| -1. In the Azure portal, select the Azure Cache for Redis instance where you want to configure Microsoft Entra token-based authentication. |
| 84 | +1. In the Azure portal, select the Azure Redis cache where you want to create the data access policy. |
103 | 85 |
|
104 |
| -1. From the Resource menu, select **Data Access configuration**. |
| 86 | +1. Select **Data Access Configuration** under **Settings** in the left navigation menu. |
105 | 87 |
|
106 | 88 | :::image type="content" source="media/cache-configure-role-based-access-control/cache-data-access-configuration.png" alt-text="Screenshot showing Data Access Configuration highlighted in the Resource menu.":::
|
107 | 89 |
|
108 |
| -1. Select **Add** and choose **New Access Policy**. |
| 90 | +1. On the **Data Access Configuration** page, select **Add** > **New Access Policy**. |
109 | 91 |
|
110 |
| - :::image type="content" source="media/cache-configure-role-based-access-control/cache-add-custom-policy.png" alt-text="Screenshot showing a form to add custom access policy."::: |
| 92 | +1. On the **Add/Edit a custom access policy** screen, provide a name for your access policy. |
111 | 93 |
|
112 |
| -1. Provide a name for your access policy. |
| 94 | +1. Under **Permissions**, add your custom permissions string, and then select **Apply**. |
113 | 95 |
|
114 |
| -1. [Configure Permissions](#permissions-for-your-data-access-policy) as per your requirements. |
| 96 | + :::image type="content" source="media/cache-configure-role-based-access-control/cache-add-custom-policy.png" alt-text="Screenshot showing a form to add custom access policy."::: |
115 | 97 |
|
116 |
| -1. To add a user to the access policy using Microsoft Entra ID, you must first enable Microsoft Entra ID by selecting **Authentication** from the Resource menu. |
| 98 | +The custom policy now appears on the **Access Policies** tab of the **Data Access Configuration** page, along with the three built-in Azure Redis policies. |
117 | 99 |
|
118 |
| -1. Select **Enable Microsoft Entra Authentication** as the tab in the working pane. |
| 100 | +### Enable Microsoft Entra authentication |
119 | 101 |
|
120 |
| -1. If not checked already, check the box labeled **Enable Microsoft Entra Authentication** and select **OK**. Then, select **Save**. |
| 102 | +To assign a user to an access policy by using Microsoft Entra, you must have Microsoft Entra rather than Access Keys authentication enabled on your cache. To check your authentication method, select **Authentication** under **Settings** in the left navigation menu for your cache. |
121 | 103 |
|
122 |
| - :::image type="content" source="media/cache-azure-active-directory-for-authentication/cache-enable-microsoft-entra.png" alt-text="Screenshot of Microsoft Entra ID access authorization."::: |
| 104 | +On the **Authentication** screen, if **Disable Access Keys Authentication** is selected and no access keys appear on the screen, your cache already uses Microsoft Entra authentication. Otherwise, select the checkbox next to **Disable Access Keys Authentication** and then select **Save**. |
123 | 105 |
|
124 |
| -1. A popup dialog box displays asking if you want to update your configuration, and informing you that it takes several minutes. Select **Yes.** |
| 106 | +:::image type="content" source="media/cache-configure-role-based-access-control/enable-entra.png" alt-text="Screenshot of disabling access keys authentication."::: |
| 107 | + |
| 108 | +Respond **Yes** to the popup dialog box asking if you want to disable access keys authentication. |
125 | 109 |
|
126 |
| - > [!IMPORTANT] |
127 |
| - > Once the enable operation is complete, the nodes in your cache instance reboots to load the new configuration. We recommend performing this operation during your maintenance window or outside your peak business hours. The operation can take up to 30 minutes. |
| 110 | +> [!IMPORTANT] |
| 111 | +> Once the Microsoft Entra enable operation is complete, the nodes in your cache instance reboot to load the new configuration. The operation can take up to 30 minutes. It's best to perform this operation during your maintenance window or outside peak business hours. |
128 | 112 |
|
129 | 113 | ## Configure your Redis client to use Microsoft Entra ID
|
130 | 114 |
|
131 |
| -Now that you have configured Redis User and Data access policy for configuring role based access control, you need to update your client workflow to support authenticating using a specific user/password. To learn how to configure your client application to connect to your cache instance as a specific Redis User, see [Configure your Redis client to use Microsoft Entra](cache-azure-active-directory-for-authentication.md#configure-your-redis-client-to-use-microsoft-entra). |
| 115 | +Most Azure Cache for Redis clients assume that a password and access key are used for authentication. You might need to update your client workflow to support authentication and authorization using a specific Microsoft Entra user name and password. To learn how to configure your client application to connect to your cache instance as a specific Redis user, see [Configure your Redis client to use Microsoft Entra ID](cache-azure-active-directory-for-authentication.md#configure-your-redis-client-to-use-microsoft-entra). |
132 | 116 |
|
133 |
| -## Next steps |
| 117 | +## Related content |
134 | 118 |
|
135 | 119 | - [Use Microsoft Entra ID for cache authentication](cache-azure-active-directory-for-authentication.md)
|
| 120 | +- [Azure role-based access control in the Azure portal](/azure/role-based-access-control/role-assignments-portal) |
0 commit comments