CREATE ARTIFACT REPOSITORY
statementsupportedContainer services & dev toolingCreates a new artifact repository in the current or specified schema, or replaces an existing artifact repository. An artifact repository stores versioned packages that are used by downstream Snowflake objects. Two repository types are supported: - APPLICATION: stores packaged application builds that a CREATE APPLICATION SERVICE deploys. - PYPI: stores Python packages resolved from an external Python package index through an API integration.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] ARTIFACT REPOSITORY [ IF NOT EXISTS ] <name>
TYPE = { APPLICATION | PYPI }
[ API_INTEGRATION = '<integration_name>' ]
[ INDEX_URL = '<url>' ]
[ AUTHENTICATION_SECRET = <secret_name> ]
[ PACKAGE_RETENTION = { ON_OBJECT_CREATION } ]
[ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , ... ] ) ]
[ COMMENT = '<string_literal>' ]
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Specifies the identifier for the artifact repository. The identifier must be unique for the schema where the repository is created. For more details, see Identifier requirements. |
TYPE = { APPLICATION | PYPI } | required | Specifies the type of content the repository stores. APPLICATION: stores versioned application packages. Required when the repository is referenced by CREATE APPLICATION SERVICE. PYPI: stores Python packages fetched from an external package index. The API_INTEGRATION parameter is required for this type. |
API_INTEGRATION = 'integration_name' | optional | Specifies the API integration that provides access to the external Python package index. Required when TYPE = PYPI. Not used when TYPE = APPLICATION. |
INDEX_URL = 'url' | optional | Specifies the HTTPS URL of the PyPI-compatible package index that a customer-hosted Python artifact repository fetches packages from (for example, 'https://nexus.example.com/repository/pypi-proxy/simple/'). The host must be covered by the API_ALLOWED_PREFIXES of the referenced API integration. Used only for customer-hosted PyPI repositories. |
AUTHENTICATION_SECRET = secret_name | optional | Specifies the secret that Snowflake uses to authenticate to the customer-hosted Python artifact repository. The secret must be included in the ALLOWED_AUTHENTICATION_SECRETS of the referenced API integration. Used only for customer-hosted PyPI repositories. |
PACKAGE_RETENTION = ON_OBJECT_CREATION | optional | Controls when Snowflake retains packages downloaded from a customer-hosted Python artifact repository: When not set (default), packages are retained asynchronously in the background after each CREATE FUNCTION or CREATE PROCEDURE. When set to ON_OBJECT_CREATION, CREATE FUNCTION and CREATE PROCEDURE download and retain every referenced package before the statement returns. For details, see Package retention and caching. Used only for customer-hosted PyPI repositories. |
TAG ( tag_name = 'tag_value' [ , ... ] ) | optional | Assigns a tag to the repository. For more details about object tagging, see Introduction to object tagging. |
COMMENT = 'string_literal' | optional | Specifies a comment for the artifact repository. DEFAULT: No value |
Usage notes
- An APPLICATION repository holds one or more packages. Each package has one or more versions. New versions are produced by builds that target the repository. For more information, see Get started with Snowflake App Runtime.
- A repository’s type can’t be changed after it’s created. To switch types, drop the repository and create a new one.
- CREATE OR REPLACE drops and recreates the repository atomically. All packages and versions in the repository are removed.
- 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 ARTIFACT REPOSITORY | Schema | Required to create a new artifact repository in the schema. USAGE | API integration | Required only when TYPE = PYPI. The following privileges can be granted on an artifact repository after it’s created: Privilege | Object | Notes OWNERSHIP | Artifact repository | Grants full control, including publishing new package versions and dropping the repository. READ | Artifact repository | Allows downloading packages and artifacts. Grant this to any role that references the repository in CREATE APPLICATION SERVICE. 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.
See also
- ALTER ARTIFACT REPOSITORY
- DESCRIBE ARTIFACT REPOSITORY
- DROP ARTIFACT REPOSITORY
- SHOW ARTIFACT REPOSITORIES
- SHOW FILES IN ARTIFACT REPOSITORY
- SHOW PACKAGES IN ARTIFACT REPOSITORY
- SHOW VERSIONS IN ARTIFACT REPOSITORY