CREATE APPLICATION SERVICE

Creates a new Application Service that deploys a packaged application build from an artifact repository.

An Application Service is a first-class Snowflake object. It manages its own compute, lifecycle, and access control. Unlike a Snowpark Container Services service, an Application Service deploys from a versioned package rather than from a user-supplied service specification.

See also:

ALTER APPLICATION SERVICE , DESCRIBE APPLICATION SERVICE , DROP APPLICATION SERVICE , SHOW APPLICATION SERVICES

Syntax

CREATE APPLICATION SERVICE [ IF NOT EXISTS ] <name>
  FROM ARTIFACT REPOSITORY <repository_name> PACKAGE <package_name>
  [ VERSION <version_alias> ]
  [ IN COMPUTE POOL <compute_pool_name> ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
  [ QUERY_WAREHOUSE = <warehouse_name> ]
  [ AUTO_RESUME = { TRUE | FALSE } ]
  [ AUTO_SUSPEND_SECS = <num> ]
  [ COMMENT = '<string_literal>' ]

Required parameters

name

Specifies the identifier for the Application Service. The identifier must be unique for the schema where the service is created. For more details, see Identifier requirements.

The Application Service doesn’t share a namespace with SPCS SERVICE objects.

FROM ARTIFACT REPOSITORY repository_name PACKAGE package_name

Specifies the artifact repository and package to deploy. The repository must be of type APPLICATION.

During public preview, you must include FROM ARTIFACT REPOSITORY. Omitting the repository clause isn’t supported.

Optional parameters

VERSION version_alias

Specifies the version of the package to deploy. You can pass a version name, such as VERSION$3, or a version alias, such as LATEST or DEFAULT. If you don’t specify a version, Snowflake uses the package’s default version; if the package has no default version, the command returns an error.

IN COMPUTE POOL compute_pool_name

Specifies a Snowpark Container Services compute pool for the Application Service.

During Snowflake App Runtime public preview, managed compute pools are enforced by default: Snowflake uses the account-level managed pool for the service, and user-specified pool values aren’t used.

EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] )

Specifies the names of the external access integrations that allow the application to access external network locations. The names in this list are case-sensitive.

QUERY_WAREHOUSE = warehouse_name

Specifies the warehouse used by the application when a container connects to Snowflake without explicitly specifying a warehouse.

AUTO_RESUME = { TRUE | FALSE }

Specifies whether Snowflake automatically resumes the service when it receives an inbound request to one of its endpoints.

AUTO_SUSPEND_SECS = num

Specifies the number of seconds of inactivity after which Snowflake automatically suspends the Application Service. The minimum non-zero value is 300. A value of 0 disables auto-suspend.

DEFAULT: 0 (disabled)

COMMENT = 'string_literal'

Specifies a comment for the Application Service.

Access control requirements

If your role does not own the objects in the following table, then your role must have the listed privileges on those objects:

PrivilegeObjectNotes
CREATE APPLICATION SERVICESchemaRequired to create a new Application Service in the schema.
READArtifact repositoryRequired on the artifact repository that contains the package.
USAGECompute pool

Required only when your account is configured to allow user-selected compute pools. During public preview, Snowflake uses the managed compute pool by default.

USAGEExternal access integrationRequired for each integration listed in EXTERNAL_ACCESS_INTEGRATIONS.
USAGEWarehouseRequired if QUERY_WAREHOUSE is specified.

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

  • The Application Service starts automatically after creation. To check its status, use SHOW APPLICATION SERVICES or DESCRIBE APPLICATION SERVICE.
  • During public preview, Snowflake runs Application Services on a managed compute pool by default, including requests that specify IN COMPUTE POOL.
  • To upgrade the service to a different package version, use ALTER APPLICATION SERVICE with UPGRADE.
  • Standalone SPCS SQL commands, such as CREATE SERVICE and EXECUTE JOB SERVICE, aren’t used to manage an Application Service. Use APPLICATION SERVICE commands instead.
  • CREATE OR REPLACE isn’t supported for Application Services.
  • You must specify FROM ARTIFACT REPOSITORY with the repository name. Commands that specify only FROM PACKAGE without a repository aren’t supported.
  • Snowflake App Runtime isn’t available on trial accounts.
  • The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
  • CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.

Examples

Deploy the default version of a package from an artifact repository:

CREATE APPLICATION SERVICE my_app
  FROM ARTIFACT REPOSITORY my_app_repo PACKAGE web_ui;

Deploy a specific version:

CREATE APPLICATION SERVICE my_app
  FROM ARTIFACT REPOSITORY my_app_repo PACKAGE web_ui
  VERSION VERSION$3
  EXTERNAL_ACCESS_INTEGRATIONS = ( my_eai )
  QUERY_WAREHOUSE = my_warehouse
  AUTO_RESUME = TRUE
  AUTO_SUSPEND_SECS = 600
  COMMENT = 'Customer portal';

Deploy the LATEST alias:

CREATE APPLICATION SERVICE my_app
  FROM ARTIFACT REPOSITORY my_app_repo PACKAGE web_ui
  VERSION LATEST;