Native App Framework: Build & Distribute Declarative Apps
Learn to build and distribute Snowflake Native Apps using the Declarative Apps framework.
20+ years shipping high-throughput database systems. Lessons pulled from things that broke in production.
- ✓Basic SQL knowledge (SELECT, CREATE, GRANT)
- ✓A Snowflake account with ACCOUNTADMIN privileges
- ✓Familiarity with YAML syntax
- ✓Optional: Python for Streamlit UI development
- Snowflake Native Apps are applications built on Snowflake that run within the Snowflake environment.
- The Declarative Apps framework simplifies app development by using SQL and YAML manifests.
- Apps can be distributed via the Snowflake Marketplace or shared directly.
- Key components: manifest.yml, setup script, application package, and provider account.
- Use cases include data clean rooms, analytics dashboards, and ML inference apps.
Think of Snowflake Native Apps like building a custom app for your phone, but instead of running on your phone, it runs inside Snowflake. The Declarative Apps framework is like a recipe book: you write down what you want (ingredients and instructions) in a simple format, and Snowflake builds the app for you. You can then share that app with others, like publishing it in an app store.
Imagine you've built a powerful data pipeline that cleans and transforms raw data into actionable insights. You want to share this pipeline with other teams or even external customers, but they don't have your exact setup. Traditionally, you'd have to export data, write documentation, and hope they can replicate your environment. Snowflake Native Apps change that: you can package your entire application—including logic, user interfaces, and data—into a single entity that runs inside Snowflake, leveraging Snowflake's compute and security.
The Snowflake Native App Framework, especially with the Declarative Apps paradigm, allows you to define your app using SQL and YAML manifests. This approach reduces boilerplate code and lets you focus on the business logic. In this tutorial, you'll learn how to build a declarative Snowflake Native App from scratch, deploy it, and distribute it via the Snowflake Marketplace. We'll cover the architecture, step-by-step creation, debugging in production, and common pitfalls. By the end, you'll be able to create your own native apps that can be shared securely and efficiently.
Understanding Snowflake Native App Architecture
Snowflake Native Apps are built on the concept of an Application Package, which is a container that holds all the components of the app: the manifest, setup script, stored procedures, Streamlit UIs, and any other artifacts. The app runs in a consumer's Snowflake account but is managed by the provider. The key components are:
- Provider Account: The account where the app is developed and from which it is shared or published.
- Application Package: A versioned collection of the app's files. It can be shared with consumer accounts or published on the Marketplace.
- Manifest (manifest.yml): A YAML file that defines the app's metadata, required privileges, and references to other files.
- Setup Script: A SQL script that runs when the app is installed. It creates the app's objects (e.g., schemas, tables, procedures) within the app's sandbox.
- App Roles: Roles defined in the setup script that control access to app objects.
- Streamlit App: Optional UI component for interactive dashboards.
The Declarative Apps framework simplifies this by allowing you to define the app's behavior using SQL and YAML without writing complex code. The manifest declares what the app needs, and Snowflake handles the rest.
Setting Up Your Development Environment
To build a Snowflake Native App, you need a Snowflake account with the ACCOUNTADMIN role (or a role with CREATE APPLICATION PACKAGE privilege). You'll also need a stage to upload your app files. Here's how to set up:
- Create a new database and schema for your app development.
- Create a stage (internal or external) to store your app files.
- Create an application package using SQL.
- Upload your manifest, setup script, and any other files to the stage.
- Alter the application package to add a version.
Let's walk through an example. We'll create a simple app that reads from a shared database and returns aggregated results.
Creating the Application Package and Version
Once your files are ready, you need to create an application package and add a version. The application package is a container that holds all versions of your app. Here's the SQL to do that:
- Create the application package.
- Add a version by pointing to the stage where your files are located.
- Optionally, add a default release directive for the latest version.
After creating the package, you can share it with other accounts or publish it to the Marketplace.
ALTER APPLICATION PACKAGE ... ADD PATCH command for hotfixes without changing the version label. This allows consumers to update seamlessly.Installing the App in a Consumer Account
To test your app, you can install it in a different account (or a different role in the same account). The consumer must have the IMPORT SHARE privilege to install the app. Here's the process:
- The provider shares the application package with the consumer account.
- The consumer creates an application from the shared package.
- The setup script runs, creating the app's objects.
- The consumer can then use the app's stored procedures and Streamlit UIs.
Let's see how the consumer installs the app.
Adding a Streamlit UI to Your App
Snowflake Native Apps can include Streamlit apps for interactive user interfaces. To add a Streamlit app, you need to include it in the manifest and upload the Python file to the stage. The Streamlit app runs within Snowflake and can call the app's stored procedures.
Here's an example Streamlit app that displays the results from our stored procedure.
Distributing Your App via the Snowflake Marketplace
Once your app is ready, you can list it on the Snowflake Marketplace to reach a wider audience. The Marketplace allows consumers to discover and install your app with a few clicks. To publish:
- Ensure your application package is complete and tested.
- Create a listing in the Marketplace via the Snowflake UI or SQL.
- Provide a compelling description, pricing (if any), and support information.
- Approve the listing after review.
Here's how to create a listing using SQL.
SYSTEM$GET_APP_USAGE function to track installations and usage patterns.The Case of the Missing App: A Snowflake Native App Deployment Failure
privileges: [USAGE, SELECT] on the shared database) and re-uploaded the app package. The consumer had to reinstall the app to apply the new manifest.- Always declare all required privileges in the manifest.yml.
- Test app installation in a separate consumer account before publishing.
- Understand that Snowflake Native Apps are sandboxed and need explicit permissions.
- Use the
DESCRIBE APPLICATION PACKAGEcommand to verify manifest details. - Document the required privileges for consumers in the app listing.
SHOW GRANTS TO APPLICATION <app_name> to see current grants.manifest_version, name, version) are present.SHOW GRANTS TO APPLICATION <app_name>;DESCRIBE APPLICATION PACKAGE <package_name>;| File | Command / Code | Purpose |
|---|---|---|
| manifest.yml | manifest_version: 1 | Understanding Snowflake Native App Architecture |
| setup.sql | CREATE SCHEMA IF NOT EXISTS app_schema; | Setting Up Your Development Environment |
| create_package.sql | CREATE APPLICATION PACKAGE my_app_package | Creating the Application Package and Version |
| install_app.sql | CREATE APPLICATION my_app | Installing the App in a Consumer Account |
| dashboard.py | session = snowpark.Session.builder.configs(st.secrets["snowflake"]).create() | Adding a Streamlit UI to Your App |
| create_listing.sql | CREATE APPLICATION PACKAGE LISTING my_app_listing | Distributing Your App via the Snowflake Marketplace |
Key takeaways
Common mistakes to avoid
3 patternsForgetting to declare required privileges in the manifest.
Using hardcoded database names in the setup script.
Not testing the app in a consumer account before publishing.
Interview Questions on This Topic
What is a Snowflake Native App and how does it differ from a traditional application?
Frequently Asked Questions
20+ years shipping high-throughput database systems. Lessons pulled from things that broke in production.
That's Snowflake. Mark it forged?
3 min read · try the examples if you haven't