Add Snowflake App Runtime to a Snowflake Native App (Preview)

You can include a Snowflake App Runtime app in a Snowflake Native App and create an Application Service when a consumer installs the Native App. You can also use the Application Service as the Native App’s default UI.

As a provider, you build the App Runtime app first, then declare its artifact package in the Native App’s manifest. The setup script creates an Application Service from the app declared in the manifest.

You can distribute your Native App to consumers in other regions where both the Snowflake Native App Framework and Snowflake App Runtime on serverless compute are available. For cloud and account availability, see the Native App Framework cloud support matrix and the App Runtime availability requirements.

To distribute across regions, set up auto-fulfillment for your listing:

Limitations

  • Application Services created from a package declared in the Native App manifest require serverless compute.
  • PrivateLink isn’t supported for Snowflake App Runtime apps that use serverless compute.
  • CREATE OR ALTER APPLICATION SERVICE isn’t supported in development mode for Native Apps created from stage files. See Test in development mode.

Prerequisites

Before you declare an App Runtime app in the Native App’s manifest:

  1. Create the App Runtime app. See Get started with Snowflake App Runtime.
  2. Configure the app to use serverless compute. Set compute_resource: SERVERLESS in the App Runtime project’s app.yml version 2 manifest. See Serverless configuration for configuration examples and prerequisites for serverless compute.
  3. Build and deploy the app so that its published package version is available in an APPLICATION artifact repository. See Deploy an app to Snowflake App Runtime.
  4. Create an application package with a Native App manifest and setup script. See Create and manage an application package.

The App Runtime project’s app.yml and the Native App’s manifest.yml serve different purposes. app.yml configures how the App Runtime app is built and deployed, including its compute resource. manifest.yml declares which built app to include in the Native App and identifies the setup script that creates the Application Service.

Find the artifact package and version

To list the packages in the source artifact repository, run SHOW PACKAGES IN ARTIFACT REPOSITORY:

SHOW PACKAGES IN ARTIFACT REPOSITORY provider_db.app_schema.app_repo;

To list the published versions of a package, run SHOW VERSIONS IN ARTIFACT REPOSITORY:

SHOW VERSIONS IN ARTIFACT REPOSITORY provider_db.app_schema.app_repo
  FOR PACKAGE sales_dashboard;

Only fully published versions appear in the output. Use a version name returned by this command, or specify LATEST in the Native App manifest to include the most recently published version.

Note

For a standalone App Runtime app, use SHOW APPLICATION SERVICES or DESCRIBE APPLICATION SERVICE to find the deployed package and version to declare in your Native App manifest.

For an Application Service installed as part of a Native App, these commands report the deployed package and version but don’t show the source package or version declared in the manifest. The deployed version identifier is expected to differ from the source version identifier.

Declare the App Runtime app in the manifest

Add a snowflake_apps entry under artifacts in the Native App’s manifest.yml. The following example declares the source package sales_dashboard with the name dashboard:

manifest_version: 2

artifacts:
  setup_script: scripts/setup.sql
  snowflake_apps:
    - name: dashboard
      artifact_repository: provider_db.app_schema.app_repo
      package: sales_dashboard
      version: LATEST

Each entry identifies an App Runtime app to include in the Native App version:

name

The name of the app declared in the manifest, such as dashboard in the example. This field is required. The name must conform to the requirements for an unquoted Snowflake identifier and must be no more than 60 characters long.

artifact_repository

The source artifact repository that contains the built App Runtime app.

package

The name of the package in the source artifact repository. This field is optional. If you omit it, Snowflake uses the name of the app declared in the manifest.

version

The artifact package version to include in the Native App. Specify a published version name returned by SHOW VERSIONS IN ARTIFACT REPOSITORY, or LATEST to include the most recently published version. Set this field explicitly to select the version to package with the Native App.

Configure the default UI

To use an Application Service as the Native App’s default UI, set artifacts.default_web_endpoint.application_service to the schema-qualified name of the Application Service created by the setup script:

artifacts:
  setup_script: scripts/setup.sql
  default_web_endpoint:
    application_service: app_schema.dashboard_service
  snowflake_apps:
    - name: dashboard
      artifact_repository: provider_db.app_schema.app_repo
      package: sales_dashboard
      version: LATEST

In this example, app_schema.dashboard_service is the Application Service created in the setup script. It isn’t the app name dashboard declared under snowflake_apps or the source artifact package name sales_dashboard.

Only one of default_web_endpoint and default_streamlit can be specified in the manifest.

Create the Application Service in the setup script

Use CREATE APPLICATION SERVICE in the Native App’s setup script to create a service from the app declared in the manifest. Set FROM PACKAGE to the name of the app declared under artifacts.snowflake_apps. For example, the following statement uses dashboard from the manifest example:

CREATE SCHEMA IF NOT EXISTS app_schema;

CREATE APPLICATION SERVICE IF NOT EXISTS app_schema.dashboard_service
  FROM PACKAGE dashboard
  COMPUTE_RESOURCE = SERVERLESS;

The service uses the app declared in the Native App manifest. The following rules apply:

  • The FROM PACKAGE value must match an app name declared under artifacts.snowflake_apps in the installed version’s manifest.
  • You can’t specify VERSION. The artifact package version is determined by the installed Native App version.

The Native App form of the command supports the following syntax:

CREATE APPLICATION SERVICE [ IF NOT EXISTS ] <name>
  FROM PACKAGE <app_name_in_manifest>
  COMPUTE_RESOURCE = SERVERLESS
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
  [ QUERY_WAREHOUSE = <warehouse_name> ]
  [ AUTO_RESUME = { TRUE | FALSE } ]
  [ AUTO_SUSPEND_SECS = <num> ]
  [ COMMENT = '<string_literal>' ]

For descriptions of the optional parameters, see CREATE APPLICATION SERVICE.

Grant access to an application role

Grant USAGE on the Application Service to an application role in the setup script:

CREATE APPLICATION ROLE IF NOT EXISTS app_user;

GRANT USAGE ON SCHEMA app_schema TO APPLICATION ROLE app_user;
GRANT USAGE ON APPLICATION SERVICE app_schema.dashboard_service
  TO APPLICATION ROLE app_user;

For information about application roles, see Create the setup script.

Add a Native App version or patch

Add versions and patches using the existing Native App workflow. For example:

ALTER APPLICATION PACKAGE my_app_package ADD VERSION v1
  USING '@my_app_package.app_schema.app_stage/v1';

To add a patch:

ALTER APPLICATION PACKAGE my_app_package ADD PATCH FOR VERSION v1
  USING '@my_app_package.app_schema.app_stage/v1';

For more information, see ALTER APPLICATION PACKAGE … VERSION.

The artifact package version and the Native App version are separate. In these examples, v1 is the Native App version. The version field under snowflake_apps selects the artifact package version to include in v1.

When you specify LATEST, the artifact package version is resolved when you add the Native App version or patch. Publishing another App Runtime build doesn’t change the artifact package already included in that Native App version or patch.

Security scans

For application packages with external distribution, Snowflake scans the App Runtime app for security vulnerabilities. The scan includes the application source and its downloaded dependencies.

For information about the Native App security review, see Security requirements and guidelines for a Snowflake Native App.

Upgrade the Application Service

The Native App’s version initializer must upgrade the Application Service to the package version Snowflake resolves from the target manifest. If the service isn’t on that version after the initializer runs, the Native App upgrade fails.

Before releasing a Native App upgrade, verify that the Application Service exists in a test installation by running SHOW APPLICATION SERVICES. In the target manifest, find the App Runtime app under artifacts.snowflake_apps and check that its version field selects the intended source package version. For the difference between the source version in the manifest and the deployed package version, see Find the artifact package and version.

To upgrade the service, include the following statement in the Native App’s version initializer callback:

ALTER APPLICATION SERVICE IF EXISTS app_schema.dashboard_service UPGRADE;

TO VERSION isn’t supported. Snowflake uses the manifest for the Native App version whose initializer is running to resolve the service’s target package version.

To define and declare the callback, see Use a version initializer to manage service upgrades. Include ALTER APPLICATION SERVICE ... UPGRADE in the initializer for every version, including the version consumers currently have installed.

If the installed version’s initializer doesn’t run ALTER APPLICATION SERVICE ... UPGRADE, release a patch for that version that adds the command. Verify that affected consumers have installed the patch before releasing the next version. The patch enables recovery only for consumers whose Native Apps are already running it.

If the target setup script or version initializer fails, the previous Native App version remains active. Snowflake calls that version’s initializer if one is configured. If the initializer contains ALTER APPLICATION SERVICE ... UPGRADE, Snowflake resolves the package version for the previous Native App version and attempts to restore the service. If the previous version doesn’t have a suitable initializer, or if recovery fails, the service might not be restored and manual intervention might be needed.

After the upgrade, confirm that the Native App reached the intended version and test the Application Service in the upgraded app. A successful Native App upgrade confirms that the service passed Snowflake’s package-version check.

For information about upgrading a Native App, see Update an app (Legacy).

Test in development mode

CREATE OR ALTER APPLICATION SERVICE isn’t supported for Native Apps created in development mode from stage files. Use separate CREATE APPLICATION SERVICE and ALTER APPLICATION SERVICE statements instead, as shown in the setup-script examples on this page.

For information about testing a Native App from stage files, see Install and test an app locally.