Bird
Raised Fist0
SnowflakeHow-ToBeginner · 3 min read

How to Create a Stage for Azure in Snowflake

To create a stage for Azure in Snowflake, use the CREATE STAGE command with the URL pointing to your Azure Blob Storage container and specify STORAGE_INTEGRATION or CREDENTIALS for authentication. This sets up a reference to your Azure storage for loading or unloading data.
📐

Syntax

The CREATE STAGE command defines a named location in Azure Blob Storage for Snowflake to access data files. Key parts include:

  • stage_name: Your chosen name for the stage.
  • URL: The Azure Blob Storage container URL, starting with azure://.
  • STORAGE_INTEGRATION or CREDENTIALS: How Snowflake authenticates to Azure.
  • FILE_FORMAT: Optional, defines the format of files in the stage.
sql
CREATE STAGE stage_name
  URL='azure://<storage_account>.blob.core.windows.net/<container_name>'
  STORAGE_INTEGRATION = integration_name
  FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);
💻

Example

This example creates a stage named azure_stage pointing to an Azure Blob Storage container using a storage integration named azure_int. It also sets a CSV file format.

sql
CREATE STAGE azure_stage
  URL='azure://mystorageaccount.blob.core.windows.net/mycontainer'
  STORAGE_INTEGRATION = azure_int
  FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = ',' SKIP_HEADER = 1);
Output
Stage 'azure_stage' created.
⚠️

Common Pitfalls

  • Using incorrect URL format: The URL must start with azure:// and include the storage account and container.
  • Missing or misconfigured STORAGE_INTEGRATION: Ensure the integration has proper permissions to access Azure Blob Storage.
  • Not specifying FILE_FORMAT when loading files can cause errors if the default format doesn't match your files.
sql
/* Wrong: Missing STORAGE_INTEGRATION */
CREATE STAGE bad_stage
  URL='azure://mystorage.blob.core.windows.net/container';

/* Right: Include STORAGE_INTEGRATION */
CREATE STAGE good_stage
  URL='azure://mystorage.blob.core.windows.net/container'
  STORAGE_INTEGRATION = my_integration;
📊

Quick Reference

ParameterDescriptionExample
stage_nameName of the stage to createazure_stage
URLAzure Blob Storage container URLazure://mystorage.blob.core.windows.net/container
STORAGE_INTEGRATIONSnowflake integration for Azure authenticationazure_int
FILE_FORMATDefines file type and options(TYPE='CSV' FIELD_DELIMITER=',' SKIP_HEADER=1)
✅

Key Takeaways

Use CREATE STAGE with the azure:// URL to link Snowflake to Azure Blob Storage.
Always specify STORAGE_INTEGRATION or CREDENTIALS for secure access.
Define FILE_FORMAT to match your data files for smooth loading.
Check URL format carefully to avoid connection errors.
Test stage creation with simple commands before loading data.