Create an online store instance

To set up online serving, you need to first create an online store instance for Bigtable online serving or Optimized online serving. To understand the differences between Bigtable online serving and Optimized online serving, see Online serving types.

Note that you can't change the type of online serving after you choose Bigtable online serving or Optimized online serving while creating your online store. However, you can change the serving endpoint configuration for an online store instance created for Optimized online serving.

After you create the online store, you can add feature views and associate those feature views with feature data sources in BigQuery.

You can encrypt your online store instance by specifying a customer-managed encryption key (CMEK) when you create your online store instance. Only Bigtable online serving supports encryption using a CMEK. To learn more about the benefits of using a CMEK and to understand whether a CMEK is useful for your online store, see Benefits of CMEK.

Using a CMEK can involve additional usage costs, depending on the type of key being used. For more information about pricing, refer to Cloud Key Management Service pricing.

Before you begin

Authenticate to Vertex AI, unless you've done so already.

Select the tab for how you plan to use the samples on this page:

Console

When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

Python

To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment.

REST

To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

    Install the Google Cloud CLI, then initialize it by running the following command:

    gcloud init

For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

Create an online store for Bigtable online serving

When you use Bigtable online serving, you have the option to encrypt the online store using a CMEK.

Create an online store for Bigtable online serving without CMEK

To create an online store instance for Bigtable online serving with autoscaling, without specifying a CMEK, use the Google Cloud console or the REST API.

Console

Use the following instructions to create an online store for Bigtable online serving using the Google Cloud console.

  1. In the Vertex AI section of the Google Cloud console, go to the Feature Store page.

    Go to the Feature Store page

  2. Click Online store to go to the Online store section.

  3. Click Create to open the Create Online Store page.

  4. Specify a name for the online store.

  5. Optional: To add labels, click Add label, and specify the label name and value. You can add multiple labels to an online store.

  6. In the Choose a storage solution for your online store field, click Bigtable.

  7. Modify the Minimum node count, Maximum node count, and CPU utilization target, as needed.

  8. Click Create.

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.


from google.cloud import aiplatform
from vertexai.resources.preview import feature_store


def create_bigtable_feature_online_store_sample(
    project: str,
    location: str,
    feature_online_store_id: str,
):
    aiplatform.init(project=project, location=location)
    fos = feature_store.FeatureOnlineStore.create_bigtable_store(
        feature_online_store_id
    )
    return fos

  • project: Your project ID.
  • location: Region where the online store is located, such as us-central1.
  • feature_online_store_id: The name of the new FeatureOnlineStore instance.

REST

To create a FeatureOnlineStore resource, send a POST request by using the featureOnlineStores.create method.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the online store, such as us-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the new online store instance.
  • BOOLEAN: Optional: To create an online store that supports embedding management, enter true. The default value is false.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME

Request JSON body:

{
  "bigtable": {
    "auto_scaling": {
      "min_node_count": 1,
      "max_node_count": 3,
      "cpu_utilization_target": 50
    }
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

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

Save the request body in a file named request.json, and execute the following command:

$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

You should receive a JSON response similar to the following:

{
  "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"
    }
  }
}

Create an online store that uses a CMEK

Use the following steps to create an online store instance for Bigtable online serving that's encrypted with a CMEK.

Using a CMEK encryption can involve additional usage costs, depending on the type of key being used. For more information about pricing, refer to Cloud Key Management Service pricing.

  1. Use Cloud Key Management Service to configure a customer-managed encryption key.

  2. To create a FeatureOnlineStore resource, send the following POST request by using the featureOnlineStores.create method and specifying the CMEK.

    Before using any of the request data, make the following replacements:

    • LOCATION_ID: Region where you want to create the online store, such as us-central1.
    • PROJECT_ID: Your project ID.
    • FEATUREONLINESTORE_NAME: The name of the new online store instance.
    • BOOLEAN: Optional: To create an online store that supports embedding management, enter true. The default value is false.
    • KEY_NAME: The name of the encryption key that you want to use for this metadata store.

    HTTP method and URL:

    POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME

    Request JSON body:

    {
      "bigtable": {
        "auto_scaling": {
          "min_node_count": 1,
          "max_node_count": 3,
          "cpu_utilization_target": 50
        }
      },
      "encryption_spec": {
        "kms_key_name": "KEY_NAME"
      }
    }
    

    To send your request, choose one of these options:

    curl

    Save the request body in a file named request.json, and execute the following command:

    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

    Save the request body in a file named request.json, and execute the following command:

    $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

    You should receive a JSON response similar to the following:

    {
      "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"
        }
      }
    }
    

Create an online store for Optimized online serving

When you use Optimized online serving, you can configure the online store to serve features from either a public endpoint or a dedicated Private Service Connect endpoint. Use a Private Service Connect endpoint if you want to serve features within a VPC network at lower latencies than a public endpoint.

Create an online store for Optimized online serving with a public endpoint

Use the following samples to create an online store for Optimized online serving with a public endpoint.

Console

Use the following instructions to create an online store for Optimized online serving using the Google Cloud console.

  1. In the Vertex AI section of the Google Cloud console, go to the Feature Store page.

    Go to the Feature Store page

  2. Click Online store to go to the Online store section.

  3. Click Create to open the Create Online Store page.

  4. Specify a name for the online store.

  5. Optional: To add labels, click Add label, and specify the label name and value. You can add multiple labels to an online store.

  6. In the Choose a storage solution for your online store field, click Optimized.

  7. Click Create.

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.


from google.cloud import aiplatform
from vertexai.resources.preview import feature_store


def create_optimized_public_feature_online_store_sample(
    project: str,
    location: str,
    feature_online_store_id: str,
):
    aiplatform.init(project=project, location=location)
    fos = feature_store.FeatureOnlineStore.create_optimized_store(
        feature_online_store_id
    )
    return fos

  • project: Your project ID.
  • location: Region where you want to create the FeatureOnlineStore instance, such as us-central1.
  • feature_online_store_id: The name of the new FeatureOnlineStore instance.

REST

To create an online store instance, send a POST request by using the featureOnlineStores.create method.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the FeatureOnlineStore instance, such as us-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the new FeatureOnlineStore instance.

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME

Request JSON body:

{
  "optimized": {}
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

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

Save the request body in a file named request.json, and execute the following command:

$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

You should receive a JSON response similar to the following:

{
  "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"
    }
  }
}

Create an online store for Optimized online serving with a Private Service Connect endpoint

Use the following samples to create an online store for Optimized online serving with Private Service Connect.

Python

To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.


from typing import List

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store


def create_optimized_private_feature_online_store_sample(
    project: str,
    location: str,
    feature_online_store_id: str,
    project_allowlist: List[str],
):
    aiplatform.init(project=project, location=location)
    fos = feature_store.FeatureOnlineStore.create_optimized_store(
        name=feature_online_store_id,
        enable_private_service_connect=True,
        project_allowlist=project_allowlist,
    )
    return fos

  • project: Your project ID.
  • location: Region where you want to create the FeatureOnlineStore instance, such as us-central1.
  • feature_online_store_id: The name of the new FeatureOnlineStore instance.
  • project_allowlist: The list of project names to be allowlisted for private service connect (PSC).

REST

To create an online store instance, send a POST request by using the featureOnlineStores.create method.

Before using any of the request data, make the following replacements:

  • LOCATION_ID: Region where you want to create the FeatureOnlineStore instance, such as us-central1.
  • PROJECT_ID: Your project ID.
  • FEATUREONLINESTORE_NAME: The name of the new FeatureOnlineStore instance.
  • PROJECT_NAMES: The list of project names to be allowlisted for private service connect (PSC).

HTTP method and URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores?feature_online_store_id=FEATUREONLINESTORE_NAME

Request JSON body:

{
  "optimized": {},
  "dedicated_serving_endpoint": {
    "private_service_connect_config": {
      "enable_private_service_connect": true,
      "project_allowlist": ["PROJECT_NAMES"]
    }
  }
}

To send your request, choose one of these options:

curl

Save the request body in a file named request.json, and execute the following command:

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

Save the request body in a file named request.json, and execute the following command:

$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

You should receive a JSON response similar to the following:

{
  "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"
    }
  }
}

What's next