如需设置在线传送,您需要先为 Bigtable 在线传送或优化的在线传送(已弃用)创建在线存储区实例。
请注意,创建在线存储区时,选择 Bigtable 在线传送或优化的在线传送后,您便无法更改在线传送的类型。但是,您可以更改为优化的在线传送创建的在线存储区实例的服务端点配置。
创建在线存储区后,您可以添加特征视图,并将这些特征视图与 BigQuery 中的特征数据源关联。
您可以在创建在线存储区实例时指定客户管理的加密密钥 (CMEK),以加密在线存储区实例。只有 Bigtable 在线传送支持使用 CMEK 进行加密。如需详细了解使用 CMEK 的好处,以及了解 CMEK 是否适合您的在线存储区,请参阅使用 CMEK 的好处。
使用 CMEK 可能会产生额外的使用费用,具体取决于所使用的密钥类型。如需详细了解价格,请参阅 Cloud Key Management Service 价格。
准备工作
向 Gemini Enterprise Agent Platform 进行身份验证,除非您已完成此操作。
选择标签页以了解您打算如何使用本页面上的示例:
控制台
当您使用 Google Cloud 控制台访问 Google Cloud 服务和 API 时,无需设置身份验证。
Python
如需在本地开发环境中使用本页面上的 Python 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭据设置应用默认凭据。
-
安装 Google Cloud CLI。
-
配置 gcloud CLI 以使用您的联合身份。
如需了解详情,请参阅使用联合身份登录 gcloud CLI。
-
为您的用户账号创建本地身份验证凭证:
gcloud auth application-default login
如果系统返回身份验证错误,并且您使用的是外部身份提供方 (IdP),请确认您已 使用联合身份登录 gcloud CLI。
如需了解详情,请参阅 为本地开发环境设置身份验证。
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭证。
安装 Google Cloud CLI,然后 使用联合身份登录 gcloud CLI。
如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证。
为 Bigtable 在线传送创建在线存储区
使用 Bigtable 在线传送时,您可以选择使用 CMEK 对在线存储区进行加密。
为 Bigtable 在线传送创建不使用 CMEK 的在线存储区
如需为具有自动扩缩的 Bigtable 在线传送创建在线存储区实例,而不指定 CMEK,请使用 Google Cloud 控制台或 REST API。
控制台
请按照以下说明使用 Google Cloud 控制台为 Bigtable 在线传送创建在线存储区。
在 Google Cloud 控制台的 Agent Platform 部分中,前往 Feature Store 页面。
点击在线存储区以转到在线存储区部分。
点击创建,打开创建在线存储区页面。
指定在线存储区的名称。
可选:若要添加标签,请点击添加标签,然后指定标签名称和值。您可以为在线存储区添加多个标签。
在为您的在线存储区选择存储解决方案字段中,点击 Bigtable。
根据需要修改节点数下限、节点数上限和 CPU 利用率目标。
点击创建。
Python
如需了解如何安装或更新 Vertex AI SDK for Python,请参阅安装 Vertex AI SDK for Python。 如需了解详情,请参阅 Python API 参考文档。
project:您的项目 ID。location:在线存储区所在的区域,例如us-central1。feature_online_store_id:新FeatureOnlineStore实例的名称。
REST
如需创建 FeatureOnlineStore 资源,请使用 featureOnlineStores.create 方法发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:要在其中创建在线存储区的区域,例如
us-central1。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:新的在线存储区实例的名称。
- BOOLEAN(可选):如需创建支持嵌入管理的在线存储区,请输入
true。默认值为false。
HTTP 方法和网址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
请求 JSON 正文:
{
"bigtable": {
"auto_scaling": {
"min_node_count": 1,
"max_node_count": 3,
"cpu_utilization_target": 50
}
}
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"
PowerShell
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata",
"genericMetadata": {
"createTime": "2023-09-18T17:49:23.847496Z",
"updateTime": "2023-09-18T17:49:23.847496Z"
}
}
}
创建使用 CMEK 的在线存储区
按照以下步骤创建在线存储区实例,用于通过 CMEK 加密的 Bigtable 在线传送。
使用 CMEK 加密可能会产生额外的使用费用,具体取决于所使用的密钥类型。如需详细了解价格,请参阅 Cloud Key Management Service 价格。
如需创建
FeatureOnlineStore资源,请使用 featureOnlineStores.create 方法发送以下POST请求并指定 CMEK。在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:要在其中创建在线存储区的区域,例如
us-central1。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:新的在线存储区实例的名称。
- BOOLEAN(可选):如需创建支持嵌入管理的在线存储区,请输入
true。默认值为false。 - KEY_NAME:您要用于此元数据存储区的加密密钥的名称。
HTTP 方法和网址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
请求 JSON 正文:
{ "bigtable": { "auto_scaling": { "min_node_count": 1, "max_node_count": 3, "cpu_utilization_target": 50 } }, "encryption_spec": { "kms_key_name": "KEY_NAME" } }如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为
request.json的文件中,然后执行以下命令:curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"PowerShell
将请求正文保存在名为
request.json的文件中,然后执行以下命令:$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content您应该收到类似以下内容的 JSON 响应:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata", "genericMetadata": { "createTime": "2023-09-18T17:49:23.847496Z", "updateTime": "2023-09-18T17:49:23.847496Z" } } }- LOCATION_ID:要在其中创建在线存储区的区域,例如
为优化的在线传送创建在线存储区
使用优化的在线传送时,您可以将在线存储区配置为从公共端点或专用 Private Service Connect 端点传送特征。
为通过公共端点进行优化的在线传送创建在线存储区
使用以下示例创建在线存储区,用于通过公共端点进行优化的在线传送。
控制台
请按照以下说明使用 Google Cloud 控制台为优化的在线传送创建在线存储区。
在 Google Cloud 控制台的 Agent Platform 部分中,前往 Feature Store 页面。
点击在线存储区以转到在线存储区部分。
点击创建,打开创建在线存储区页面。
指定在线存储区的名称。
可选:若要添加标签,请点击添加标签,然后指定标签名称和值。您可以为在线存储区添加多个标签。
在为您的在线存储区选择存储解决方案字段中,点击优化。
点击创建。
Python
如需了解如何安装或更新 Vertex AI SDK for Python,请参阅安装 Vertex AI SDK for Python。 如需了解详情,请参阅 Python API 参考文档。
project:您的项目 ID。location:要在其中创建FeatureOnlineStore实例的区域,例如us-central1。feature_online_store_id:新FeatureOnlineStore实例的名称。
REST
如需创建在线存储区实例,请使用 featureOnlineStores.create 方法发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:要在其中创建
FeatureOnlineStore实例的区域,例如us-central1。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:新
FeatureOnlineStore实例的名称。
HTTP 方法和网址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
请求 JSON 正文:
{
"optimized": {}
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"
PowerShell
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata",
"genericMetadata": {
"createTime": "2023-09-18T17:49:23.847496Z",
"updateTime": "2023-09-18T17:49:23.847496Z"
}
}
}
为通过 Private Service Connect 端点进行优化的在线传送创建在线存储区
使用以下示例为通过 Private Service Connect 进行优化的在线传送创建在线存储区。
Python
如需了解如何安装或更新 Vertex AI SDK for Python,请参阅安装 Vertex AI SDK for Python。 如需了解详情,请参阅 Python API 参考文档。
project:您的项目 ID。location:要在其中创建FeatureOnlineStore实例的区域,例如us-central1。feature_online_store_id:新FeatureOnlineStore实例的名称。project_allowlist:要列入 Private Service Connect (PSC) 许可名单的项目名称列表。
REST
如需创建在线存储区实例,请使用 featureOnlineStores.create 方法发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- LOCATION_ID:要在其中创建
FeatureOnlineStore实例的区域,例如us-central1。 - PROJECT_ID:您的项目 ID。
- FEATUREONLINESTORE_NAME:新
FeatureOnlineStore实例的名称。 - PROJECT_NAMES:要列入 Private Service Connect (PSC) 许可名单的项目名称列表。
HTTP 方法和网址:
POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME
请求 JSON 正文:
{
"optimized": {},
"dedicated_serving_endpoint": {
"private_service_connect_config": {
"enable_private_service_connect": true,
"project_allowlist": ["PROJECT_NAMES"]
}
}
}
如需发送请求,请选择以下方式之一:
curl
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME"
PowerShell
将请求正文保存在名为 request.json 的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME" | Select-Object -Expand Content
您应该收到类似以下内容的 JSON 响应:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOnlineStoreOperationMetadata",
"genericMetadata": {
"createTime": "2023-09-18T17:49:23.847496Z",
"updateTime": "2023-09-18T17:49:23.847496Z"
}
}
}