Create and manage an application package

This topic describes how providers can create an application package to develop a Snowflake Native App.

About the application package

An application package is a container that encapsulates the data content and application logic used by a Snowflake Native App. An application package also contains information about versions and patches defined for an app.

Each version of an app requires its own version of the manifest and setup script:

manifest file:

The manifest file contains information that the application package requires to create and manage a Snowflake Native App. This includes the location of the setup script, version definitions, and configuration information for the app.

For more information, see 为应用程序创建清单文件.

setup script:

The setup script contains SQL statements that are run when the app is installed, either in the consumer account or locally during development and testing.

For more information, see Create the setup script.

备注

You can create an application package without creating the manifest file or setup script. However, to develop or test an app, you must upload these files to a stage so they are accessible to the application package.

About release channels

Release channels manage the release lifecycle of Snowflake Native Apps. They allow providers to create and manage versions of an app and to publish the app at different stages of development to all consumers or specific groups of consumers.

小心

When you create an application package, release channels are enabled by default. After release channels have been enabled for an application package, they can't be disabled.

For more information on using release channels to manage the release lifecycle of an app, see 使用版本渠道发布应用程序.

To use the previous process for managing versions and patches you must explicitly disable release channels when creating the application package. However, for new app development Snowflake recommends using release channels to manage the release lifecycle of your apps.

For information on using the older features for managing versions and patches, see Develop a new version of an app (Legacy).

创建应用程序包时所需的权限

要创建应用程序包,您的角色必须获授全局 CREATE APPLICATION PACKAGE 权限。

创建应用程序包

You can create an application package using one of the following methods:

Create an application package using Snowsight

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » App packages.

  3. 选择 Create,然后点击右侧窗格中的 App Package

  4. 输入应用程序包的名称。

  5. 选择应用程序包的预期使用者:

    • 选择 Distribute to accounts outside of your organization,使该应用程序包可在您的组织外部使用。选择此选项将为应用程序包中定义的每个版本和补丁启动 自动安全扫描

    • 选择 Distribute to accounts in your organization,使该应用程序包可在您的组织内部使用。自动安全扫描不会启动。

  6. (可选)为应用程序包输入注释。使用者看不到这些注释。

  7. 选择 Add

使用 SQL 命令创建应用程序包

要使用 SQL 创建应用程序包,请使用 CREATE APPLICATION PACKAGE 命令,如以下示例所示:

CREATE APPLICATION PACKAGE my_application_package;
Copy

This command creates an application package named my_application_package in your Snowflake account. By default, release channels are enabled for the application package.

创建应用程序包后,使用 SHOW APPLICATION PACKAGES 命令查看可用应用程序包列表。

Create an application package using the Snowflake CLI

If you are using the Snowflake CLI to develop an app, the application package is created when you run the Snow 应用程序运行 command. This command creates an application package in your Snowflake account, uploads code files to a stage, then creates or upgrades an app from the application package.

Grant the required privileges on an application package

Some tasks related to creating or using an application package require specific privileges on the application package. The following table describes the privileges required to perform these tasks:

权限

任务

ATTACH LISTING

将应用程序包添加到列表。

DEVELOP

从应用程序包创建一个处于开发模式的 APPLICATION 对象。

INSTALL

基于应用程序包创建一个 APPLICATION 对象。

MANAGE RELEASES

指定发布指令、查看版本和补丁级别。

MANAGE VERSIONS

向应用程序包添加版本和补丁级别。

OWNERSHIP

执行上述所有任务。

Grant privileges on an application package using Snowsight

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » App packages.

  3. 选择应用程序包,然后选择 Settings 选项卡。

  4. Privileges 部分中,选择要授予的权限旁边的编辑图标。

  5. 选择 Add Role,然后选择想要授予权限的角色。

  6. 选择 Save

角色会显示在权限旁边。

使用 SQL 命令授予应用程序包的权限

要使用 SQL 向角色授予对应用程序包的权限,请使用 GRANT <privileges> ... TO ROLE 命令,如以下示例所示:

GRANT MANAGE RELEASES ON APPLICATION PACKAGE hello_snowflake_package TO ROLE app_release_mgr;
Copy

此命令会向 app_release_mgr 角色授予 MANAGE RELEASES 权限。您可以使用相同的命令,授予一个应用程序包的其他可用权限。

设置应用程序包的默认发布指令

A release directive determines the version and patch of an app that is available to a consumer when they install the app or when an installed app is automatically upgraded. For information on setting the release directive, see Set the release directive for an app (Legacy)

允许使用者安装一个应用程序的多个实例

提供商可以配置应用程序包,允许使用者安装一个应用程序的多个实例。

要启用应用程序的多个实例,请使用 CREATE APPLICATION PACKAGEMULTIPLE_INSTANCES = TRUE 子句或 ALTER APPLICATION PACKAGE 命令。

如果允许安装一个应用程序的多个实例,使用者最多可在其账户中安装 10 个实例。

无法为试用版或付费列表中所含的应用程序包设置此属性。

小心

MULTIPLE_INSTANCES 属性设置为 TRUE 后,无法取消设置或将其设置为 FALSE

转移应用程序包的所有权

创建应用程序包后,可以将该应用程序包的所有权转移给另一个账户级角色。

使用 Snowsight 转移所有权

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » App packages.

  3. 选择要转移所有权的应用程序包旁边的 ...,然后选择 Transfer Ownership

  4. Transfer to 下选择新的账户级角色。

  5. 选择 Transfer

使用 SQL 命令转移所有权

要使用 SQL 将应用程序包的所有权转移到另一个账户级别角色,请使用 GRANT OWNERSHIP 命令,如以下示例所示:

GRANT OWNERSHIP ON APPLICATION PACKAGE hello_snowflake_package TO ROLE native_app_dev;
Copy

删除应用程序包

Providers with the OWNERSHIP privilege on an application package can remove it from an account. However, providers cannot remove an application package that is currently associated with a listing.

After removing an application package, it is no longer available in the provider account.

小心

移除列表和随附的应用程序包后,使用者可以查看但不能访问从该应用程序包创建的 Snowflake Native App。如果使用者尝试访问 Snowflake Native App,则会收到一条错误消息,指明该应用程序包已被移除。

Delete an application package using Snowsight

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » App packages.

  3. 选择要移除的应用程序包旁边的 ...,然后选择 Drop

Delete an application package using SQL commands

要使用 SQL 移除应用程序包,请运行 DROP APPLICATION PACKAGE 命令,如以下示例所示:

DROP APPLICATION PACKAGE hello_snowflake_package;
Copy
语言: 中文