Skip to content

Commit 22cd079

Browse files
committed
conceptual article review
1 parent 26f7d97 commit 22cd079

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: What is secret injection in online endpoints (preview)?
33
titleSuffix: Azure Machine Learning
4-
# title: #Required; Keep the title body to 60-65 chars max including spaces and brand
5-
# description: #Required; Keep the description within 100- and 165-characters including spaces
64
description: Learn about secret injection as it applies to online endpoints in Azure Machine Learning.
75
services: machine-learning
86
ms.service: machine-learning
@@ -13,7 +11,7 @@ ms.author: sehan
1311
ms.reviewer: mopeakande
1412
reviewer: msakande
1513
ms.custom: ignite-2023
16-
ms.date: 01/02/2024
14+
ms.date: 01/10/2024
1715

1816
#CustomerIntent: As an ML Pro, I want to retrieve and inject secrets into the deployment environment easily so that deployments I create can consume the secrets in a secured manner.
1917
---
@@ -22,73 +20,77 @@ ms.date: 01/02/2024
2220

2321
[!INCLUDE [dev v2](includes/machine-learning-dev-v2.md)]
2422

25-
Secret injection in the context of an online endpoint is a process of retrieving secrets (such as API keys) from secret stores, and injecting them into your user container that runs inside an online deployment. Secrets will eventually be accessible via environment variables, thereby providing a secure way for them to be consumed by the inference server that runs your scoring script or by the inferencing stack that you bring with a BYOC (bring your own container) deployment approach.
23+
Secret injection in the context of an online endpoint is a process of retrieving secrets (such as API keys) from secret stores, and injecting them into your user container that runs inside an online deployment. Secrets are eventually accessed securely via environment variables, which are used by the inference server that runs your scoring script or by the inferencing stack that you bring with a BYOC (bring your own container) deployment approach.
2624

2725
[!INCLUDE [machine-learning-preview-generic-disclaimer](includes/machine-learning-preview-generic-disclaimer.md)]
2826

2927
## Problem statement
3028

31-
When you create an online deployment, you might want to use secrets from within the deployment to access external services. These external services could include Microsoft Azure OpenAI service, Azure AI Services, Azure AI Content Safety, and so on.
29+
When you create an online deployment, you might want to use secrets from within the deployment to access external services. Some of these external services include Microsoft Azure OpenAI service, Azure AI Services, and Azure AI Content Safety.
3230

33-
However, you have to find a way to securely pass secrets to your user container that runs inside the deployment. We don't recommend that you include secrets as part of the deployment definition—a practice that exposes the secrets in the deployment definition. A better approach is to store the secrets in secret stores and then retrieve them from within the deployment in a secure manner. This approach poses its own challenge—how can a deployment authenticate itself to the secret stores to retrieve secrets?
31+
To use the secrets, you have to find a way to securely pass them to your user container that runs inside the deployment. We don't recommend that you include secrets as part of the deployment definition, since this practice would expose the secrets in the deployment definition.
3432

35-
The online deployment runs your user container using the endpoint identity, which is a [managed identity](/entra/identity/managed-identities-azure-resources/overview). Use of the managed identity means that you can use [Azure RBAC](../role-based-access-control/overview.md) to control the endpoint identity's permissions and allow the endpoint to retrieve secrets from the secret stores. You can see this [example that shows how to use managed identities to interact with external services](https://github.com/Azure/azureml-examples/tree/main/cli/endpoints/online/managed/managed-identities) and extend it to retrieve secrets in your deployment. This approach requires you to do the following tasks:
33+
A better approach is to store the secrets in secret stores and then retrieve them securely from within the deployment. However, this approach poses its own challenge: how the deployment should authenticate itself to the secret stores to retrieve secrets. Because the online deployment runs your user container using the _endpoint identity_, which is a [managed identity](/entra/identity/managed-identities-azure-resources/overview), you can use [Azure RBAC](../role-based-access-control/overview.md) to control the endpoint identity's permissions and allow the endpoint to retrieve secrets from the secret stores.
34+
Using this approach requires you to do the following tasks:
3635

3736
- Assign the right roles to the endpoint identity so that it can read secrets from the secret stores.
3837
- Implement the scoring logic for the deployment so that it uses the endpoint's managed identity to retrieve the secrets from the secret stores.
3938

40-
While this approach of using a managed identity is a secure way to retrieve secrets, the secret injection feature simplifies the process further for [workspace connections](prompt-flow/concept-connections.md) and [key vaults](../key-vault/general/overview.md).
39+
While this approach of using a managed identity is a secure way to retrieve and inject secrets, [secret injection via the secret injection feature](#secret-injection-via-the-secret-injection-feature) further simplifies the process of retrieving secrets for [workspace connections](prompt-flow/concept-connections.md) and [key vaults](../key-vault/general/overview.md).
4140

4241

4342
## Managed identity associated with the endpoint
4443

45-
An online deployment runs your user container with the managed identity associated with the endpoint. This managed identity, the _endpoint identity_, is a [Microsoft Entra ID](/entra/fundamentals/whatis) that supports [Azure RBAC](../role-based-access-control/overview.md). Therefore, you can assign Azure roles to the identity to control permissions that are required to perform operations. This endpoint identity can be either a system-assigned identity (SAI) or a user-assigned identity (UAI). You can decide whether to use an SAI or a UAI when you create the endpoint.
44+
45+
An online deployment runs your user container with the managed identity associated with the endpoint. This managed identity, called the _endpoint identity_, is a [Microsoft Entra ID](/entra/fundamentals/whatis) that supports [Azure RBAC](../role-based-access-control/overview.md). Therefore, you can assign Azure roles to the identity to control permissions that are required to perform operations. The endpoint identity can be either a system-assigned identity (SAI) or a user-assigned identity (UAI). You can decide which of these kinds of identities to use when you create the deployment.
4646

4747
- For a _system-assigned identity_, the identity is created automatically when you create the endpoint, and roles with fundamental permissions (such as the Azure Container Registry pull permission and the storage blob data reader) are automatically assigned.
4848
- For a _user-assigned identity_, you need to create the identity first, and then associate it with the endpoint when you create the endpoint. You're also responsible for assigning proper roles to the UAI as needed.
4949

50-
For more information on using managed identities of an endpoint, see [How to access resources from endpoints with managed identities](how-to-access-resources-from-endpoints-managed-identities.md), and an [example for using managed identities](https://github.com/Azure/azureml-examples/tree/main/cli/endpoints/online/managed/managed-identities).
50+
For more information on using managed identities of an endpoint, see [How to access resources from endpoints with managed identities](how-to-access-resources-from-endpoints-managed-identities.md), and the example for [using managed identities to interact with external services](https://github.com/Azure/azureml-examples/tree/main/cli/endpoints/online/managed/managed-identities).
5151

5252

53-
## Role assignment to the endpoint's identity
53+
## Role assignment to the endpoint identity
5454

55-
__Roles required by the secret stores__:
55+
The following roles are required by the secret stores:
5656

57-
- If your secrets are stored in workspace connections under your workspace: `Workspace Connections` provides a [List Secrets API (preview)](/rest/api/azureml/2023-08-01-preview/workspace-connections/list-secrets) that requires the identity that calls the API to have `Azure Machine Learning Workspace Connection Secrets Reader` role (or equivalent) assigned to the identity.
58-
- If your secrets are stored in an external Microsoft Azure Key Vault: Key Vault provides a [Get Secret Versions API](/rest/api/keyvault/secrets/get-secret-versions/get-secret-versions) that requires the identity that calls the API to have `Key Vault Secrets User` role (or equivalent) assigned to the identity.
57+
- For __secrets stored in workspace connections under your workspace__: `Workspace Connections` provides a [List Secrets API (preview)](/rest/api/azureml/2023-08-01-preview/workspace-connections/list-secrets) that requires the identity that calls the API to have `Azure Machine Learning Workspace Connection Secrets Reader` role (or equivalent) assigned to the identity.
58+
- For __secrets stored in an external Microsoft Azure Key Vault__: Key Vault provides a [Get Secret Versions API](/rest/api/keyvault/secrets/get-secret-versions/get-secret-versions) that requires the identity that calls the API to have `Key Vault Secrets User` role (or equivalent) assigned to the identity.
5959

6060

6161
## Implementation of secret injection
6262

63-
There are two ways to inject secrets:
63+
Once secret (such as API keys) are retrieved from secret stores, there are two ways to inject them into a user container that runs inside the online deployment:
6464

6565
- Inject secrets yourself, using managed identities.
6666
- Inject secrets, using the secret injection feature.
6767

6868
Both of these approaches involve two steps:
6969

70-
1. First, retrieve secrets from the secret stores using endpoint identity.
71-
1. Second, inject into your user container.
70+
1. First, retrieve secrets from the secret stores, using the endpoint identity.
71+
1. Second, inject the secrets into your user container.
7272

7373
### Secret injection via the use of managed identities
7474

75-
In your deployment definition, you need to use the endpoint identity to call the APIs from secret stores. This logic can be implemented in your scoring script, or in shell scripts that you run in your BYOC container. You can implement this logic by extending the [example for using managed identities](https://github.com/Azure/azureml-examples/tree/main/cli/endpoints/online/managed/managed-identities).
75+
In your deployment definition, you need to use the endpoint identity to call the APIs from secret stores. You can implement this logic either in your scoring script or in shell scripts that you run in your BYOC container. To implement secret injection via the use of managed identities, see the [example for using managed identities to interact with external services](https://github.com/Azure/azureml-examples/tree/main/cli/endpoints/online/managed/managed-identities).
7676

7777
### Secret injection via the secret injection feature
7878

79-
Instead of directly calling the APIs from workspace connections and/or the Key Vault, you can map environment variables with the secrets (that you want to refer to) from workspace connections or the Key Vault, in your deployment definition. This approach doesn't require you to write any code in your scoring script or in shell scripts that you run in your BYOC container. To map environment variables with the secrets from workspace connections or the Key Vault, the following conditions must be met:
79+
To use the secret injection feature, in your deployment definition, map environment variables onto the secrets (that you want to refer to) from workspace connections or the Key Vault. This approach doesn't require you to write any code in your scoring script or in shell scripts that you run in your BYOC container. To map environment variables onto the secrets from workspace connections or the Key Vault, the following conditions must be met:
8080

81-
- If an online endpoint was defined to enforce access to default secret stores (workspace connections under the current workspace) when the *endpoint* was created, your user identity that creates the *deployment* under the endpoint should have the permissions to read secrets from workspace connections.
81+
- During endpoint creation, if an online endpoint was defined to enforce access to default secret stores (workspace connections under the current workspace), your user identity that creates the deployment under the endpoint should have the permissions to read secrets from workspace connections.
8282
- The endpoint identity that the deployment uses should have permissions to read secrets from either workspace connections or the Key Vault, as referenced in the deployment definition.
8383

8484
> [!NOTE]
85-
> - The endpoint identity might have automatically received permission for workspace connections if the endpoint was successfully created with an SAI and the flag set to enforce access to default secret stores. In other cases, for example, if the endpoint used a UAI, or the flag wasn't set, the endpoint identity might not have the permission for workspace connections. In such a situation, you need to perform the task of assigning the role for the workspace connections to the endpoint identity.
86-
> - The endpoint identity won't automatically receive permission for the external Key Vault. You'll need to manually assign the role for the Key Vault to the endpoint identity, if you are using the Key Vault as a secret store.
85+
> - If the endpoint was successfully created with an SAI and the flag set to enforce access to default secret stores, then the endpoint would automatically have the permission for workspace connections.
86+
> - In the case where the endpoint used a UAI, or the flag to enforce access to default secret stores wasn't set, then the endpoint identity might not have the permission for workspace connections. In such a situation, you need to manually assign the role for the workspace connections to the endpoint identity.
87+
> - The endpoint identity won't automatically receive permission for the external Key Vault. If you're using the Key Vault as a secret store, you'll need to manually assign the role for the Key Vault to the endpoint identity.
8788
8889
For more information on using secret injection, see [Deploy machine learning models to online endpoints with secret injection (preview)](how-to-deploy-online-endpoint-with-secret-injection.md).
8990

9091

9192
## Related content
9293

93-
- [Online endpoints](concept-endpoints-online.md)
9494
- [Deploy machine learning models to online endpoints with secret injection (preview)](how-to-deploy-online-endpoint-with-secret-injection.md)
95+
- [Authentication for managed online endpoints](concept-endpoints-online-auth.md)
96+
- [Online endpoints](concept-endpoints-online.md)

0 commit comments

Comments
 (0)