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:
- For a Marketplace listing, see Set up auto-fulfillment for an application package.
- For a private listing, see Set up auto-fulfillment with SQL.
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 SERVICEisn’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:
- Create the App Runtime app. See Get started with Snowflake App Runtime.
- Configure the app to use serverless compute. Set
compute_resource: SERVERLESSin the App Runtime project’sapp.ymlversion 2 manifest. See Serverless configuration for configuration examples and prerequisites for serverless compute. - Build and deploy the app so that its published package version is available in
an
APPLICATIONartifact repository. See Deploy an app to Snowflake App Runtime. - 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:
To list the published versions of a package, run SHOW VERSIONS IN ARTIFACT REPOSITORY:
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:
Each entry identifies an App Runtime app to include in the Native App version:
nameThe name of the app declared in the manifest, such as
dashboardin 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_repositoryThe source artifact repository that contains the built App Runtime app.
packageThe 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.
versionThe artifact package version to include in the Native App. Specify a published version name returned by
SHOW VERSIONS IN ARTIFACT REPOSITORY, orLATESTto 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:
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:
The service uses the app declared in the Native App manifest. The following rules apply:
- The
FROM PACKAGEvalue must match an app name declared underartifacts.snowflake_appsin 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:
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:
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:
To add a patch:
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:
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.