| 1 | # Using Relic with Azure Key Vault |
| 2 | |
| 3 | Relic can use keys and certificates stored in an Azure Key Vault to sign. |
| 4 | |
| 5 | ## Keys |
| 6 | |
| 7 | Relic can use either certificates or keys not associated with a certificate. |
| 8 | If a key is used, the ID of a single key version must be provided. |
| 9 | For a certificate, the ID may be provided with or without a version. |
| 10 | In the latter case, the latest version will be selected and cached until relic is reloaded. |
| 11 | |
| 12 | For example, these are all valid key configurations: |
| 13 | |
| 14 | ```yaml |
| 15 | id: https://example.vault.azure.net/keys/my-azure-key/00112233445566778899aabbccddeeff |
| 16 | id: https://example.vault.azure.net/certificates/my-azure-key |
| 17 | id: https://example.vault.azure.net/certificates/my-azure-key/00112233445566778899aabbccddeeff |
| 18 | ``` |
| 19 | |
| 20 | If a certificate ID is provided and `x509certificate` is not set, then the certificate will be loaded from Azure Key Vault. |
| 21 | |
| 22 | Relic does not yet support generating or importing keys or certificates into Azure. |
| 23 | |
| 24 | ## Authentication |
| 25 | |
| 26 | Authenticating to Azure can be accomplished in all the usual ways. |
| 27 | This includes using secrets, certificates, managed service identity, the Azure CLI, or via a federated identity token. |
| 28 | |
| 29 | If no explicit configuration is provided to relic then azure will be configured via the process environment. |
| 30 | The default set of accepted environment variables can be found [here](https://pkg.go.dev/github.com/Azure/go-autorest/autorest/azure/auth#pkg-constants). |
| 31 | |
| 32 | For interactive use, configuring relic to use Azure CLI auth is convenient. |
| 33 | Setting pin to an empty string will enable this: |
| 34 | |
| 35 | ```yaml |
| 36 | tokens: |
| 37 | azure: |
| 38 | type: azure |
| 39 | pin: "" |
| 40 | ``` |
| 41 | |
| 42 | If modifying the environment is not desireable, or more than one account is to be used, the pin option can be used to point to a JSON file with credentials or other azure-sdk settings: |
| 43 | |
| 44 | ```yaml |
| 45 | tokens: |
| 46 | azure: |
| 47 | type: azure |
| 48 | pin: /etc/relic/mycred.json |
| 49 | ``` |
| 50 | |
| 51 | Finally, in a Kubernetes or GitHub Actions environment, a native service token can be used to authenticate using Workload Identity Federation. |
| 52 | To use this, set `AZURE_BEARER_TOKEN_FILE` to a file containing the token, and also set `AZURE_CLIENT_ID` and `AZURE_TENANT_ID` to their respective values. |
| 53 | See the [workload identity federation doc](https://docs.microsoft.com/en-us/azure/active-directory/develop/workload-identity-federation) for more details. |