Zero to One with Snowflake Native Apps

Tools and resources to get you up and running instantly

The Native Apps framework allows you to build secure and monetizable applications that run inside the Snowflake AI Data Cloud, bringing your company’s data, algorithms, and expertise to new and existing customers on your own terms. In this post, we’ll introduce tools and resources to help you get started with your development journey.

What are Native Apps?

Traditional data sharing in Snowflake happens between a data provider and consumer; providers publish data from their account(s) onto the Snowflake Marketplace using secure data shares, while customers use the same marketplace to discover and install these shares inside of their accounts. Data flows one way: from provider to consumer.

Native Apps extends this model to allow application code— either through stored procedures and functions or Snowpark Container Services — to be shared from provider to consumer as well, while ensuring that data is still only flowing in one direction. As with data shares, applications are listed on the marketplace and are installable anywhere on the data cloud.

In order to facilitate this security model, Native Apps run in secure enclaves inside of the account they are installed in. Applications publish SQL-based APIs and user interfaces and make them available through Snowflake’s powerful RBAC model, defining the interface and rules by which the consumer account can interact with the provider’s code and data, while maintaining data security on both sides.

The only things an application has access to are what the consumer explicitly shares with it. Any actions an application takes must be explicitly allowed first. Each application on the Marketplace is thoroughly vetted to ensure it is not able to exfiltrate any consumer data, while still providing the rich functionality necessary to realize your vision. You can read more about the Native Apps security model here.

Your first app, in record time

At Snowflake, customer experience is at the core of our philosophy. With more developers joining the platform and building apps, we‘ve been thinking a lot about how to simplify the first leg of the journey: deploying and experiencing your first app.

The native-apps-examples repository

To that end, we’re announcing our native-apps-examples repository widely today: the fastest way to “kick the tires” of the Native Apps framework and start building.

Screenshot showing the native-apps-examples repository landing page on GitHub

The repository contains various examples that you can clone and iterate on to build your first (or nth!) app. They range from the simple to the more complex, such as using Snowpark Container Services to run your existing code in a consumer account while still maintaining our industry-leading security model.

Each example explores a small slice of the functionality available, is self-contained, contains detailed instructions, and perhaps most importantly is deployable in your Snowflake account with minimal effort.

Prerequisite tools for local development

Because these apps run natively in the Snowflake data cloud and not on your computer, we need a way to deploy them from the source code that describes them, living in your local development environment (i.e. version-controlled source code). To that end, we provide a couple tools available to help with the deployment process:

The rest of this article will assume you have these tools installed locally and configured to connect to your Snowflake account.

Example: Hybrid Tables

Let’s explore the Hybrid Tables app, designed to show how simple they are to use in conjunction with Streamlit as part of your Native App. Hybrid tables are a natural fit for application workloads which use low-latency, transactional workloads.

Step 1: Clone the repository

To access the app, first clone the repository into your local environment using git, then open it up in VS Code.

Step 2: Explore the code

Open the hybrid-tables directory of the cloned repository in your terminal — or ideally, a code editor like VS Code. Like the other top-level folders in the repository, this one contains a self-contained example application, instructions for its deployment into your account, as well as any post-installation configuration that is required to verify functionality.

Step 3: Deploy the App

When doing local development, we recommend you use a single-account development flow where your account acts both as application provider and consumer. In this model, both the application package (provider-side) and application object (consumer-side) reside in the same account, and changes to application package flow directly to the installed application without needing to manage versions on the package.

Later, you’ll want to learn more about versions and how best to make use of them to keep your consumers up-to-date with new functionality and bug fixes. For now, we’ll leave these concepts to the side and just focus on application code and deployment for development purposes.

Snowflake CLI and the Snowflake Extension for Visual Studio Code both deploy applications in this version-less “stage development mode” by default, as well as providing isolated deployments for developers that work alongside each other in the same account.

Let’s get that application deployed. Navigate to the app’s README.md in VS Code, then click on the Snowflake tab. You will see a Native App panel that displays information about the application, as well as an Account panel that allows you to control the account the editor is connected to. After connecting to your desired account, clicking “Run (deploy and re-install)” will deploy the application package and object to your account:

Screenshot showing the Native App panel in Snowflake Extension for Visual Studio Code

Alternatively, you can use Snowflake CLI:

$ cd hybrid-tables/
$ snow app run [-c <connection>]

Whichever path you choose, you will receive a message letting you know the application package and object have been successfully created in your account, as well as a link to the URL where the application is hosted on the data cloud. Believe it or not, you’ve already deployed and installed your first app!

Step 4: Try out your new App

Follow the instructions in the README to try out the app. The particular example we’ve deployed exposes a Streamlit user interface to demonstrate the lightning-fast latency of Hybrid tables, as well as their ability to enforce a primary key constraint. To see the application you’ve just built and deployed in action, click on “Open in Browser”:

Screenshot showing a successful application deployment in VS Code

Alternatively, you can click “Open” in the Native App panel, or use Snowflake CLI to launch the application UI in your browser:

$ snow app open [-c <connection>]

Whichever method you use, you’ll be greeted with a UI in Snowsight that shows key/value pairs from a Hybrid table that lives in the application’s state, as well as a way to insert new data into it. Go ahead and interact with it — congratulations, your first Native App is working as expected!

A successfully-deployed Native App showing a Hybrid table with one row

Step 5: Iterate

You can now start playing around with the app: try making some changes to the setup script or modify the application manifest to explore new ways to request access to privileges in the consumer account.

After you make changes to non-setup files — like Streamlit python code — redeploying your application package (i.e. snow app deploy) uploads these changed files to Snowflake and makes them available to your application immediately. However, when you make changes to the setup script, application manifest, or to container images, re-installing your application (i.e. snow app run) is necessary. This command not only uploads changed files, but also re-executes the setup script. See the documentation for more information.

While you’re coding away, be sure to try out some of the more advanced examples as well.

A quick primer: don’t forget to re-deploy when you make changes to stage files (e.g. python), or re-install when you make changes to the setup script or to container images. Try out some of the more advanced examples as well.

Later, you can start a new app fresh by using any of the minimal templates available to Snowflake CLI and the Snowflake Extension for Visual Studio Code.

Step 6: Go live

When you’re ready, list your application on the Snowflake Marketplace.

Dive into the world of Native Apps

Building on the world’s most advanced data cloud has never been easier. Equipped with Snowflake CLI, the Snowflake Extension for Visual Studio Code, and the Native Apps Examples repository, you have everything you need to start mobilizing and monetizing not only your data, but your proprietary application logic as well.

If you’re still looking to get a feel for the powerful functionality on offer, check out the Snowflake Marketplace, filled with hundreds of apps that can be installed in your account and ready in minutes. These apps were built by our partners — and by Snowflake customers like you — and are already providing immense value across the entire Snowflake ecosystem.

And when you’re ready to develop, don’t forget to keep our documentation handy and remember to refer back to the examples regularly. If you’d like to see a new example, or need help with an existing one, we’d love to hear from you: we invite you to create an issue as a means of providing us feedback on how we’re doing.

We’re so excited to see what you create!

--

--