|
| 1 | +--- |
| 2 | +title: Set Up Azure Key Vault Connection in AI Foundry |
| 3 | +description: Learn how to securely connect your Azure Key Vault to AI Foundry. Follow step-by-step instructions to manage secrets and ensure seamless integration. |
| 4 | +author: jonburchel |
| 5 | +ms.author: jburchel |
| 6 | +ms.reviewer: andyaviles |
| 7 | +ms.date: 08/27/2025 |
| 8 | +ms.topic: how-to |
| 9 | +ms.service: azure-ai-foundry |
| 10 | +ai.usage: ai-assisted |
| 11 | +zone_pivot_groups: set-up-key-vault |
| 12 | +--- |
| 13 | + |
| 14 | +# Set up a Key Vault connection in Azure AI Foundry |
| 15 | + |
| 16 | +Azure Key Vault is a service for securely storing and accessing secrets. |
| 17 | +If you don't create a Key Vault connection, Azure AI Foundry stores connection details in a Microsoft-managed Azure Key Vault. The managed Key Vault doesn't appear in your Azure subscription. If you prefer to manage |
| 18 | +secrets, connect your own Azure Key Vault. |
| 19 | + |
| 20 | +> [!NOTE] |
| 21 | +> Review limitations before you set up your Key Vault connection. |
| 22 | +
|
| 23 | +## Limitations |
| 24 | + |
| 25 | +Create Azure Key Vault connections only when needed. |
| 26 | + |
| 27 | +If you bring your own Azure Key Vault, review these limitations: |
| 28 | + |
| 29 | +- One Azure Key Vault connection per AI Foundry resource is allowed. Delete an Azure Key Vault connection only if no other connections exist at the AI Foundry resource or project level. AI Foundry doesn't support secret migration, so remove and recreate connections yourself. |
| 30 | +- Deleting the underlying Azure Key Vault breaks the AI Foundry resource. Key Vault stores secrets for connections that don't use Entra ID, so any AI Foundry feature that depends on those connections stops working. |
| 31 | +- Deleting the AI Foundry resource's connection secrets stored in your bring-your-own (BYO) Azure Key Vault can break connections to other services. It may break connections to other services. |
| 32 | + |
| 33 | +::: zone pivot="ai-foundry-portal" |
| 34 | + |
| 35 | +## Create an Azure Key Vault connection |
| 36 | + |
| 37 | +Follow these steps to create a new connection to Azure Key Vault. |
| 38 | + |
| 39 | +1. Go to your project in the Azure AI Foundry portal. If you don't have a project, create a new project. |
| 40 | + |
| 41 | +1. Make sure no connections exist in the **Resource** or **Project** sections. If any exist, **Azure Key Vault** isn't available as an option. |
| 42 | + |
| 43 | +1. In the **Resource** section, select **Connected resources**. |
| 44 | + |
| 45 | +1. In the **Connected resources** section, select **+ New connection**. |
| 46 | + |
| 47 | + :::image type="content" source="../media/setup-key-vault-connection/select-azure-key-vault.jpeg" alt-text="Screenshot of the Connected resources section with the + New connection button selected, showing Azure Key Vault as an available option."::: |
| 48 | + |
| 49 | +1. Select **Azure Key Vault**. |
| 50 | + |
| 51 | + :::image type="content" source="../media/setup-key-vault-connection/azure-key-vault-connection.jpeg" alt-text="Screenshot of the Azure Key Vault selection dialog with Azure Key Vault selected."::: |
| 52 | + |
| 53 | +1. Select your **Azure Key Vault**, and then select **Connect**. |
| 54 | + |
| 55 | +::: zone-end |
| 56 | +::: zone pivot="bicep" |
| 57 | + |
| 58 | +## Create a Key Vault connection |
| 59 | + |
| 60 | +<!-- Pull this content from the [foundry-samples repository (keyvaultconnection branch)](https://github.com/andyaviles121/foundry-samples/tree/keyvaultconnection) after it's merged. |
| 61 | +
|
| 62 | +TBD - DO NOT PUBLISH WITHOUT UPDATING THIS WITH THE REAL CODE FOR THE SAMPLE. |
| 63 | +--> |
| 64 | + |
| 65 | + |
| 66 | +::: zone-end |
| 67 | + |
| 68 | +## Key Vault connection management |
| 69 | + |
| 70 | +### Creation |
| 71 | + |
| 72 | +Create a Key Vault connection only when it's the only connection. |
| 73 | +Make sure no other connections exist at the Foundry resource or project level. |
| 74 | +The service blocks Key Vault connection creation if other connections are present. |
| 75 | +If the UI doesn't show a Key Vault connection category when you choose a connection, |
| 76 | +this can be the reason. Delete other connections, and then try again. |
| 77 | + |
| 78 | +When you create a Key Vault connection, the managed Key Vault in Azure isn't used. |
| 79 | + |
| 80 | +### Deletion |
| 81 | + |
| 82 | +Before you delete an Azure Key Vault connection from AI Foundry, remove all other connections. |
| 83 | +After you remove all other connections at the Foundry resource and project levels, |
| 84 | +delete the Key Vault connection. Foundry doesn't support secret migration. |
| 85 | + |
| 86 | +### Update or change |
| 87 | + |
| 88 | +To switch from Azure Key Vault 1 to Azure Key Vault 2, delete the Azure Key Vault 1 connection, and then create the Azure Key Vault 2 connection. Follow the deletion and creation steps, and migrate any connection secrets. |
| 89 | + |
| 90 | +### Key Vault secret lifecycle |
| 91 | + |
| 92 | +When you delete connections from your managed Key Vault, the corresponding secrets are deleted. |
| 93 | +Deleting a Key Vault connection also deletes its secrets. |
| 94 | + |
| 95 | +### Granting AI Foundry access to your key vault |
| 96 | + |
| 97 | +Depending on how your key vault is provisioned, you might need to apply additional permissions. |
| 98 | +Check whether your Azure Key Vault uses role-based access control (RBAC) or access policies, and then continue. |
| 99 | + |
| 100 | +#### Role-based access control (RBAC) |
| 101 | + |
| 102 | +After you create the Key Vault connection, assign an appropriate RBAC role in the Azure portal. Key Vault Contributor or Key Vault Administrator are two roles that work. For minimal permissions, use the [Key Vault Secrets |
| 103 | +Officer](/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-officer). |
| 104 | + |
| 105 | +#### Access policies |
| 106 | + |
| 107 | +Similar to RBAC roles, assign the appropriate key vault access policy (if applicable) to the Foundry resource's managed identity. |
| 108 | + |
| 109 | +## Infrastructure as code templates |
| 110 | + |
| 111 | +As a best practice, when setting up ARM, Bicep, or Terraform templates to create resources, make sure the Azure Key Vault connection is the first connection you create, and make all other connections depend on the Key Vault connection succeeding. This order helps reduce Key Vault connection failures. If you don't follow this best practice, your templates can encounter race conditions across your connections. As a result, deployments can work sometimes and fail at other times because Foundry doesn't support secret migration. |
| 112 | + |
| 113 | +After you create the Foundry resource and the Key Vault connection, assign the appropriate RBAC roles to the Foundry resource. Make all other connections depend on this role assignment succeeding. The same applies if your Key Vault uses access policies instead of RBAC. |
| 114 | + |
| 115 | +### Follow this order in your infrastructure as code templates |
| 116 | + |
| 117 | +1. Create the Foundry resource. |
| 118 | +1. Create a Foundry project. |
| 119 | +1. Create the Azure Key Vault connection. |
| 120 | +1. Assign the appropriate RBAC role on the Key Vault for the Foundry resource. |
| 121 | +1. (Optional) Validate that the RBAC role has taken effect. |
| 122 | +1. Create any other connections at the resource or project level, and set the `dependsOn` field for steps 3 and 4. |
| 123 | + |
| 124 | +#### Deletion |
| 125 | + |
| 126 | +For cleanup, if you automate resource deletion by using templates, follow the creation steps in reverse: |
| 127 | + |
| 128 | +1. Delete all connections at the Foundry resource or project level. |
| 129 | +1. Delete the Azure Key Vault connection. |
| 130 | +1. Delete all Foundry projects. |
| 131 | +1. Delete the Foundry resource. |
| 132 | + |
| 133 | +## Related content |
| 134 | + |
| 135 | +- [Azure Key Vault documentation](/azure/key-vault/) |
| 136 | +- [AI Foundry documentation](/azure/ai-foundry/) |
0 commit comments