GET_PRESIGNED_URL

functionsupportedData loading & unloading

docs.snowflake.com ↗

File functions

Generates a pre-signed URL to a file on a stage using the stage name and relative file path as inputs. Access files in a stage using any of the following methods: - Navigate to the pre-signed URL directly in a web browser. - Retrieve a pre-signed URL in Snowsight. Click on the pre-signed URL in the results table. - Send the pre-signed URL in a request to the REST API for file support. Note When calling this function for files in an external stage that references Microsoft Azure cloud storage: This function returns output only when the Azure container that stores the blob object is accessed using a storage integration; querying the function fails if the container is accessed using a shared access signature (SAS) token you generate. The GET_PRESIGNED_URL function requires Azure Active Directory authentication to create the user delegation SAS token. For this purpose, a storage integration object stores a generated service principal for your Azure cloud storage. The Snowflake service principal is granted a role that includes the Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey permission (or action). Both the Storage Blob Data Reader and Storage Blob Data Contributor roles include this permission. For more information about this permission, see the Microsoft documentation. For more information about accessing an Azure container, see Configure an Azure container for loading data. Note For Microsoft Fabric OneLake stages, pre-signed URLs have a maximum expiration time of 60 minutes (3600 seconds) because of user delegation key constraints in Microsoft Fabric. If you specify a longer expiration time, the function returns an error.

Syntax

supportedpartialnot supportednot scored

GET_PRESIGNED_URL( @<stage_name> , '<relative_file_path>' , [ <expiration_time> ] )

Parameters

NameRequiredDescription
stage_namerequiredName of the internal or external stage where the file is stored. Note If the stage name includes spaces or special characters, it must be enclosed in single quotes (e.g. '@"my stage"' for a stage named "my stage").
relative_file_pathrequiredPath and filename of the file relative to its location on the stage.
expiration_timerequiredLength of time (in seconds) after which the short term access token expires. Default value: 3600 (60 minutes). Maximum value: If the stage uses an AWS IAM role (AWS_ROLE) to securely connect to your S3 bucket, the maximum expiration time is 3600 (60 minutes). For Microsoft Fabric OneLake stages, the maximum expiration time is 3600 (60 minutes). Otherwise, the maximum expiration time is 604800 (7 days).

Returns

Pre-signed URL of the staged file. Note This SQL function generates a pre-signed URL for the file path that you specify, even if the file does not exist on the stage. To ensure that the generated URL returns the expected file, open the URL in a web browser. If the file does not exist, the browser returns a NoSuchKey error in XML format.

Usage notes