|
| 1 | +--- |
| 2 | +description: Learn how to rotate Azure Fluid Relay access keys. |
| 3 | +title: Rotate Azure Fluid Relay access keys |
| 4 | +ms.date: 08/13/2024 |
| 5 | +ms.service: azure-fluid |
| 6 | +ms.topic: reference |
| 7 | +--- |
| 8 | + |
| 9 | +# How to rotate Fluid Relay Server access keys |
| 10 | +This article provides an overview of managing access keys (tenant keys) in Azure Fluid Relay Service. Microsoft recommends that you regularly rotate your keys for better security. |
| 11 | + |
| 12 | +## Primary / Secondary keys |
| 13 | +Customers use the access keys to sign the access tokens that are used to access Azure Fluid Relay Services. Azure Fluid Relay uses the keys to validate the tokens. |
| 14 | + |
| 15 | +Two keys are associated with each Azure Fluid Relay Service: a primary key and secondary key. The purpose of dual keys is to let you regenerate, or roll, keys, providing continuous access to your account and data. |
| 16 | + |
| 17 | +## View your access keys |
| 18 | + |
| 19 | +### [Azure portal](#tab/azure-portal) |
| 20 | +To see your access keys, search for your Azure Fluid Relay Service in the Azure portal. On the left menu of Azure Fluid Relay Service page, select **Settings**. Then, select **Access Keys**. Select the **Copy** button to copy the selected key. |
| 21 | + |
| 22 | +[](../images/rotate-tenant-keys.png#lightbox) |
| 23 | + |
| 24 | +### [PowerShell](#tab/azure-powershell) |
| 25 | +To retrieve your access keys with PowerShell, you need to install [Azure Fluid Relay module](/powershell/module/az.fluidrelay) first. |
| 26 | + |
| 27 | +```azurepowershell |
| 28 | +Install-Module Az.FluidRelay |
| 29 | +``` |
| 30 | + |
| 31 | +Then call the [Get-AzFluidRelayServerKey](/powershell/module/az.fluidrelay/get-azfluidrelayserverkey) command. |
| 32 | + |
| 33 | +```azurepowershell |
| 34 | +Get-AzFluidRelayServerKey -FluidRelayServerName <Fluid Relay Service name> -ResourceGroup <resource group> -SubscriptionId <subscription id> |
| 35 | +``` |
| 36 | + |
| 37 | +### [Azure CLI](#tab/azure-cli) |
| 38 | +To retrieve your access keys with Azure CLI, you need to install [fluid-relay](/cli/azure/fluid-relay) extension first. See [instructions](/cli/azure/azure-cli-extensions-overview). |
| 39 | + |
| 40 | +Then use [az fluid-relay server list-key](/cli/azure/fluid-relay/server?view=azure-cli-latest&preserve-view=true#az-fluid-relay-server-list-key) command to list access keys. |
| 41 | + |
| 42 | +```azurecli |
| 43 | +az fluid-relay server list-key --resource-group <resource group> --server-name <Fluid Relay Service name> |
| 44 | +``` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Rotate your access keys |
| 49 | +Two access keys are assigned so that your Azure Fluid Relay Service does not have to be taken offline when you rotate a key. Having two keys ensures that your application maintains access to Azure Fluid Relay throughout the process. You should rotate one of two keys at one time to avoid service interruptions. |
| 50 | + |
| 51 | +The process of rotating primary and secondary keys is the same. The following steps are for primary keys. |
| 52 | + |
| 53 | +### [Azure portal](#tab/azure-portal) |
| 54 | +To rotate your Azure Fluid Relay primary key in the Azure portal: |
| 55 | + |
| 56 | +1. Update the access keys in your application code to use the secondary access key for the Azure Fluid Relay. |
| 57 | + |
| 58 | +2. Navigate to your Fluid Relay Service in the Azure portal. |
| 59 | + |
| 60 | +3. Under **Settings**, select **Access key**. |
| 61 | + |
| 62 | +4. To regenerate the primary access key for your Azure Fluid Relay Service, select the **Regenerate Primary Key** button above the Access Information. |
| 63 | + |
| 64 | +5. Update the primary key in your code to reference the new primary access key. |
| 65 | + |
| 66 | +### [PowerShell](#tab/azure-powershell) |
| 67 | +To rotate your Fluid Relay primary key with PowerShell, you need to install [Azure Fluid Relay module](/powershell/module/az.fluidrelay) first. |
| 68 | + |
| 69 | +```azurepowershell |
| 70 | +Install-Module Az.FluidRelay |
| 71 | +``` |
| 72 | + |
| 73 | +Then follow steps below: |
| 74 | + |
| 75 | +1. Update the access keys in your application code to use the secondary access key for the Azure Fluid Relay. |
| 76 | + |
| 77 | +2. Call the [New-AzFluidRelayServerKey](/powershell/module/az.fluidrelay/new-azfluidrelayserverkey) command to regenerate the primary access key, as shown in the following example: |
| 78 | + |
| 79 | + |
| 80 | +```azurepowershell |
| 81 | +New-AzFluidRelayServerKey -FluidRelayServerName <Fluid Relay Service name> -ResourceGroup <resource group> -KeyName <key name> |
| 82 | +``` |
| 83 | + |
| 84 | +3. Update the primary key in your code to reference the new primary access key. |
| 85 | + |
| 86 | +### [Azure CLI](#tab/azure-cli) |
| 87 | +To rotate your Fluid Relay primary key with Azure CLI, you need to install [fluid-relay](/cli/azure/fluid-relay) extension first. See [instructions](/cli/azure/azure-cli-extensions-overview). |
| 88 | + |
| 89 | +Then follow steps below: |
| 90 | + |
| 91 | +1. Update the access keys in your application code to use the secondary access key for the Azure Fluid Relay. |
| 92 | + |
| 93 | +2. Call the [az fluid-relay server regenerate-key](/cli/azure/fluid-relay/server?view=azure-cli-latest&preserve-view=true#az-fluid-relay-server-regenerate-key) command to regenerate the primary access key, as shown in the following example: |
| 94 | + |
| 95 | +```azurecli |
| 96 | +az fluid-relay server regenerate-key --resource-group <resource group>--server-name <Fluid Relay Service name>--key-name <key name> |
| 97 | +``` |
| 98 | + |
| 99 | +3. Update the primary key in your code to reference the new primary access key. |
| 100 | + |
| 101 | +--- |
0 commit comments