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.

PACKAGE package_name

Specifies the name of the package in the artifact repository to deploy.

Optional parameters

FROM ARTIFACT REPOSITORY repository_name

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

If you omit this clause, Snowflake uses the default application artifact repository associated with the creating role.

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 the Snowpark Container Services compute pool that runs the Application Service. The role that creates the service needs the USAGE privilege on the compute pool.

If you omit this clause, the service uses a Snowflake-managed default compute pool when default compute pools are enabled for your account.

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 on the compute pool that runs the service, when you specify IN COMPUTE POOL.

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.
  • To upgrade the service to a different package version, use ALTER APPLICATION SERVICE with UPGRADE.
  • Naked 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.
  • 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 the default artifact repository (the common case when you use snow app deploy):

CREATE APPLICATION SERVICE my_app
  FROM PACKAGE web_ui;

Deploy a specific version from a named repository onto a user-supplied compute pool:

CREATE APPLICATION SERVICE my_app
  FROM ARTIFACT REPOSITORY my_app_repo PACKAGE web_ui
  VERSION VERSION$3
  IN COMPUTE POOL my_service_pool
  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;