Creating an Azure Stage¶
A stage specifies where data files are stored (i.e. “staged”) so that the data in the files can be loaded into a table.
In this Topic:
Data can be loaded directly from files in a specified Azure container or in an Azure “folder” path (i.e. key value prefix). If the path ends with
/, all of the objects in the corresponding Azure folder are loaded.
In addition to loading directly from files in Azure containers, Snowflake supports creating named external stages, which encapsulate all of the required information for staging files, including:
The Azure container where the files are staged.
The named storage integration object or Azure credentials for the container (if it is protected).
An encryption key (if the files in the container have been encrypted).
Named external stages are optional, but recommended when you plan to load data regularly from the same location. For instructions for creating an external stage, See Creating a Stage below.
Creating a Stage¶
You can create a named stage using either the web interface or SQL:
- Web Interface
Creating an External Stage¶
The following example uses SQL to create an external stage named
my_azure_stage that includes Azure credentials and a master encryption key. The stage URL references the Azure
myaccount account. The data files are stored in the
mycontainer container and
/load/files path. The stage references a named file format object called
CREATE OR REPLACE STAGE my_azure_stage URL='azure://myaccount.blob.core.windows.net/mycontainer/load/files' CREDENTIALS=(AZURE_SAS_TOKEN='?sv=2016-05-31&ss=b&srt=sco&sp=rwdl&se=2018-06-27T10:05:50Z&st=2017-06-27T02:05:50Z&spr=https,http&sig=bgqQwoXwxzuD2GJfagRg7VOS8hzNr3QLT7rhS8OFRLQ%3D') ENCRYPTION=(TYPE='AZURE_CSE' MASTER_KEY = 'kPxX0jzYfIamtnJEUTHwq80Au6NbSgPH5r4BDDwOaO8=') FILE_FORMAT = my_csv_format;
Note that the AZURE_SAS_TOKEN and MASTER_KEY values used in this example are for illustration purposes only.
By specifying a named file format object (or individual file format options) for the stage, it is not necessary to later specify the same file format options in the COPY command used to load data from the stage. For more information about file format objects and options, see CREATE FILE FORMAT.