A collection of basic examples of Azure functions that leverage a connection to Snowpark.
- Example Azure Functions with Snowpark for Python
- Contents
- Shared InterWorks Snowpark Package
- License
- Azure Functions
- Azure App Settings
- Azure App Setting: AZURE_KEY_VAULT_NAME
- Azure App Setting: AZURE_STORAGE_IDENTITY__blobServiceUri
- Azure App Setting: AZURE_STORAGE_IDENTITY__credential
- Azure App Setting: AZURE_STORAGE_IDENTITY__queueServiceUri
- Azure App Setting: SNOWFLAKE_ACCOUNT
- Azure App Setting: SNOWFLAKE_DEFAULT_DATABASE
- Azure App Setting: SNOWFLAKE_DEFAULT_SCHEMA
- Azure App Setting: SNOWFLAKE_DEFAULT_ROLE
- Azure App Setting: SNOWFLAKE_DEFAULT_WAREHOUSE
- Azure App Setting: SNOWFLAKE_USER
- Azure App Setting: SNOWFLAKE_PRIVATE_KEY_PLAIN_TEXT
- Azure App Setting: SNOWFLAKE_PRIVATE_KEY_PASSPHRASE
- Azure App Setting: SNOWFLAKE_PASSWORD
- Azure Function: connection_leveraging_app_settings_directly
- Azure Function: connection_leveraging_app_settings_directly_with_private_key
- Azure Function: connection_leveraging_app_settings_directly_with_vault_secrets
- Azure Function: connection_leveraging_interworks_submodule
- Azure Function: connection_leveraging_interworks_submodule_with_vault_secrets
- Azure Function: azure_storage_trigger_leveraging_app_settings_directly
- Azure Function: azure_storage_trigger_leveraging_app_settings_directly_with_vault_secrets
- Azure Function: azure_storage_trigger_leveraging_interworks_submodule_with_vault_secrets
- Azure App Settings
To simplify creating Snowpark sessions for the enclosed scripts, a custom module called "interworks_snowpark" has been used. This is contained in the "shared/interworks_snowpark" subdirectory. More details can be found in the InterWorks Snowpark for Python GitHub repository. This repository also contains instructions on how to configure your local environment for Snowpark for Python, and pairs well with this Definitive Guide to Snowflake Sessions with Snowpark for Python.
This project is licensed under the terms of the MIT license. InterWorks, Inc. makes this code available with no support and makes no guarantees on posted issues, pull requests, or feedback posted here. Click here to can contact InterWorks, Inc. directly.
This project leverages Azure Functions to trigger and execute Python scripts. To setup your local environment to modify/develop these functions, follow the guidance here.
When deployed to Azure, this project relies on the following environment variables which should be configured as App Settings:
This is the key vault in Azure which securely stores authentication keys and passwords.
This app setting is part of a series of settings that instruct the Azure function to leverage its own managed identity when connecting to the storage container. Specifically, this is the URI of the storage account that contains the container.
Original value: https://my-storage-account.blob.core.windows.net
This app setting is part of a series of settings that instruct the Azure function to leverage its own managed identity when connecting to the storage container and queue. Specifically, this app setting instructs the use of managed identity.
Original value: managedidentity
This app setting is part of a series of settings that instruct the Azure function to leverage its own managed identity when connecting to the storage queue. Specifically, this is the URI of the storage account that contains the queue.
Original value: https://my-storage-account.queue.core.windows.net
This is the account identifier for the Snowflake account being leveraged for the project.
This is the database within Snowflake that is leveraged for the project.
This is the schema within Snowflake that is leveraged for the project.
This is the role leveraged by the service account accessing Snowflake.
This is the warehouse leveraged by the service account accessing Snowflake.
This is the service account accessing Snowflake. This will be authenticated leveraging a private key of a matching name from within the Azure secrets vault.
This is the optional private key used to authenticate the user in Snowflake. This is only stored as plain text as this is a simple example, however it is advised to leverage managed identities and secrets vaults to access and store private keys.
This is the optional private key passphrase that pairs with the private key. As with the private key, this is only stored as plain text as this is a simple example. It is advised to leverage managed identities and secrets vaults to access and store private keys.
This is the optional password used to authenticate the user in Snowflake. This will only be leveraged if a private key is not provided. This is only stored as plain text as this is a simple example, however it is advised to leverage private keys instead of passwords, along with managed identities and secrets vaults to access and store the private keys.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function expects the Snowflake user's password to be stored as plain text in the Azure App Settings.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function expects the Snowflake user's private key to be provided as plain text in the Azure App Settings.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function expects the Snowflake user's private key to be stored as a secret in an Azure key vault.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function leverages the "interworks_snowpark" submodule and can accept either the Snowflake user's private key or their password, which should be provided as plain text in the Azure App Settings.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function leverages the "interworks_snowpark" submodule and leverages a private key stored as a secret in an Azure key vault.
This function is triggered directly using http and is not intended to be run regularly. The function simply establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings. Most notably, this particular function expects the Snowflake user's private key to be provided as plain text in the Azure App Settings.
This function is triggered by a queued message when a file is uploaded to a storage container. The function downloads the file from blob storage, expected in JSON format, and extracts a SQL statement from it. The function then establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings, and executes the SQL statement. Most notably, this particular function expects the Snowflake user's password to be stored as plain text in the Azure App Settings.
This function is triggered by a queued message when a file is uploaded to a storage container. The function downloads the file from blob storage, expected in JSON format, and extracts a SQL statement from it. The function then establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings, and executes the SQL statement. Most notably, this particular function expects the Snowflake user's private key to be stored as a secret in an Azure key vault.
This function is triggered by a queued message when a file is uploaded to a storage container. The function downloads the file from blob storage, expected in JSON format, and extracts a SQL statement from it. The function then establishes a connection to Snowflake using Snowpark for Python, leveraging the connection variables directly from the Azure App Settings, and executes the SQL statement. Most notably, this particular function leverages the "interworks_snowpark" submodule and can accept either the Snowflake user's private key or their password, which should be provided as plain text in the Azure App Settings.