CREATE APPLICATION SERVICE
statementpartialNative apps, listings & sharingCreates 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. This command supports the following variants: - CREATE OR ALTER APPLICATION SERVICE: Creates an Application Service if it doesn’t exist, or converges an existing one to the state described by a SPECIFICATION.
Syntax
supportedpartialnot supportednot scored
CREATE APPLICATION SERVICE [ IF NOT EXISTS ] <name>
FROM ARTIFACT REPOSITORY <repository_name> PACKAGE <package_name>
[ VERSION <version_alias> ]
[ COMPUTE_RESOURCE = { MANAGED_COMPUTE_POOL | SERVERLESS } ]
[ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> [ , ... ] ) ]
[ QUERY_WAREHOUSE = <warehouse_name> ]
[ EXECUTE_AS_ROLE = <role_name> ]
[ AUTO_RESUME = { TRUE | FALSE } ]
[ AUTO_SUSPEND_SECS = <num> ]
[ MIN_INSTANCES = <num> ]
[ MAX_INSTANCES = <num> ]
[ COMMENT = '<string_literal>' ]
[ SPECIFICATION = '<yaml>' ]
For more information, see CREATE OR ALTER APPLICATION SERVICE usage notes and CREATE OR ALTER <object>.
CREATE OR ALTER APPLICATION SERVICE <name>
FROM ARTIFACT REPOSITORY <repository_name> PACKAGE <package_name>
[ VERSION <version_alias> ]
[ COMPUTE_RESOURCE = { MANAGED_COMPUTE_POOL | SERVERLESS } ]
[ COMMENT = '<string_literal>' ]
SPECIFICATION = '<yaml>'
Parameters
| Name | Required | Description |
|---|---|---|
name | required | 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 | required | Specifies the artifact repository and package to deploy. The repository must be of type APPLICATION. You must include FROM ARTIFACT REPOSITORY. Omitting the repository clause isn’t supported. |
VERSION version_alias | optional | 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. |
COMPUTE_RESOURCE = { MANAGED_COMPUTE_POOL | SERVERLESS } | optional | Preview Feature — Open Available to all accounts. Specifies where the app runs. MANAGED_COMPUTE_POOL runs the app on managed compute. SERVERLESS runs the app on serverless compute, which starts the app on the first request and stops it after an idle period. See Serverless compute for Snowflake App Runtime. You can’t change the compute resource of an existing Application Service. To move an app to serverless compute, create a new service. See Move an existing app to serverless compute. DEFAULT: MANAGED_COMPUTE_POOL |
EXTERNAL_ACCESS_INTEGRATIONS = ( integration_name [ , ... ] ) | optional | 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 | optional | Specifies the warehouse used by the application when a container connects to Snowflake without explicitly specifying a warehouse. |
EXECUTE_AS_ROLE = role_name | optional | Specifies the role that Snowflake uses to run owner’s rights queries from the app and to derive caller’s rights grants. Only valid for an app created in a personal database. Requirements: The specified role must be granted to the owning user of the app. If omitted, Snowflake sets EXECUTE_AS_ROLE to the creator’s session primary role. If the specified role is no longer granted to the owning user when the app starts, startup fails. |
AUTO_RESUME = { TRUE | FALSE } | optional | Specifies whether Snowflake automatically resumes the service when it receives an inbound request to one of its endpoints. DEFAULT: TRUE A service on serverless compute always starts on request, so you can’t set AUTO_RESUME = FALSE for it. |
AUTO_SUSPEND_SECS = num | optional | Specifies the idle timeout, in seconds, for a service on serverless compute. When no request arrives for this period, Snowflake stops the app. The next request starts it again. Preview Feature — Open Available to all accounts. The value must be a multiple of 60 from 3600 through 86400 (1 hour through 24 hours). You can’t turn off the idle stop on serverless compute. A service on managed compute runs until you suspend it with ALTER APPLICATION SERVICE. For more information, see Start, stop, and scale a Snowflake App Runtime app. DEFAULT: 3600 (1 hour), which is also the minimum |
MIN_INSTANCES = num | optional | Specifies the minimum number of instances Snowflake keeps running. Snowflake never runs fewer than this, even if the app is idle. Must be at least 1. Can’t be greater than MAX_INSTANCES. DEFAULT: Not set. Defaults to 1 when MAX_INSTANCES is set. If both are unset, Snowflake runs one instance. |
MAX_INSTANCES = num | optional | Specifies the maximum number of instances Snowflake runs. Snowflake never runs more than this. Must be at least 1 and no more than 10. Can’t be less than MIN_INSTANCES. DEFAULT: Not set. If unset, this matches MIN_INSTANCES. |
COMMENT = 'string_literal' | optional | Specifies a comment for the Application Service. |
SPECIFICATION = 'yaml' | optional | Specifies an inline manifest that configures the service, as a single-quoted string or a dollar-quoted ($$ ... $$) block. When you supply a specification, Snowflake uses it as the source of truth for the properties it owns and doesn’t read the manifest packaged in the artifact repository. A specification is required with CREATE OR ALTER APPLICATION SERVICE and optional with CREATE APPLICATION SERVICE. The specification accepts the following keys. Unknown keys are an error, so a typo such as min_instance fails rather than being silently ignored. Properties that the specification owns can’t also appear as top-level clauses in the same statement. Specifying QUERY_WAREHOUSE, EXTERNAL_ACCESS_INTEGRATIONS, MIN_INSTANCES, MAX_INSTANCES, AUTO_RESUME, AUTO_SUSPEND_SECS, or EXECUTE_AS_ROLE alongside SPECIFICATION returns an error that tells you to set the property inside the specification instead. COMMENT isn’t owned by the specification, so you set it as a top-level clause.
|
label, description, icon | The display name, description, and icon for the app. icon is a path relative to the project root and can’t escape it with ../. These values appear in the additional_properties column of SHOW APPLICATION SERVICES and DESCRIBE APPLICATION SERVICE. | |
min_instances, max_instances | Equivalent to MIN_INSTANCES and MAX_INSTANCES. | |
auto_resume, auto_suspend_secs | Equivalent to AUTO_RESUME and AUTO_SUSPEND_SECS. |
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.
- 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. To create a service if it doesn’t exist or update it if it does, use CREATE OR ALTER APPLICATION SERVICE.
- 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.
- EXECUTE_AS_ROLE is set at creation time and can’t be changed with ALTER APPLICATION SERVICE.
- 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.
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: Privilege | Object | Notes CREATE APPLICATION SERVICE | Schema | Required to create a new Application Service in the schema. READ | Artifact repository | Required on the artifact repository that contains the package. USAGE | External access integration | Required for each integration listed in EXTERNAL_ACCESS_INTEGRATIONS or in the external_access_integrations key of a SPECIFICATION. USAGE | Warehouse | Required if QUERY_WAREHOUSE is specified, including as query_warehouse in a SPECIFICATION. USAGE | Role | Required on the role specified in EXECUTE_AS_ROLE, including as execute_as_role in a SPECIFICATION. The role must be granted to the owning user of the app. OWNERSHIP | Application Service | Required when CREATE OR ALTER APPLICATION SERVICE alters an existing Application Service. READ | Secret | Required on each secret listed in the secrets key of a SPECIFICATION. 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.
CREATE OR ALTER APPLICATION SERVICE usage notes
- A SPECIFICATION is required. CREATE OR ALTER APPLICATION SERVICE without one returns an error. - CREATE OR ALTER can’t be combined with IF NOT EXISTS. - The specification is the full intended state of the service. Snowflake resets every property the specification owns but doesn’t set: Omitting label, description, or icon clears it. - Omitting external_access_integrations, secrets, or environment_variables removes all of them. - Omitting auto_suspend_secs, min_instances, or max_instances returns it to its default. - Omitting query_warehouse unsets it. - Omitting auto_resume returns it to its default. To keep a value, restate it in every CREATE OR ALTER statement. - execute_as_role is applied when the service is created and can’t be changed afterward. Sending a different value for an existing service returns an error; omitting it leaves the current role in place. - The package and the artifact repository are fixed when the service is created. Naming a different package or repository for an existing service returns an error. Re-sending the current value is a no-op. - When you include a VERSION clause, Snowflake converges the service to that version after applying the specification. Because a version alias is resolved at statement time, VERSION LATEST picks up a newer version if one has been published since the last deployment. - A specification can’t be read back. It isn’t shown by DESCRIBE APPLICATION SERVICE or SHOW APPLICATION SERVICES, and GET_DDL doesn’t support Application Services. Keep the specification in source control. For CLI deploys that’s the service-level keys in app.yml; if you write the SQL yourself, send only the keys listed under SPECIFICATION. You can’t pass a whole app.yml as a specification. For more information, see Validation. - CREATE OR ALTER APPLICATION SERVICE requires the FROM ARTIFACT REPOSITORY clause.
Known gaps
- IF NOT EXISTS, VERSION, EXTERNAL_ACCESS_INTEGRATIONS, QUERY_WAREHOUSE, EXECUTE_AS_ROLE, MIN_INSTANCES, MAX_INSTANCES, COMMENT, SPECIFICATION, AUTO_RESUME = TRUE are not exercised by any test
See also
- ALTER APPLICATION SERVICE
- DESCRIBE APPLICATION SERVICE
- DROP APPLICATION SERVICE
- SHOW APPLICATION SERVICES