Support

Programmatic deployment in RStudio Connect

Follow
The deployment APIs are experimental in RStudio Connect 1.7.0 and will continue to evolve in upcoming RStudio Connect releases. Please try using these APIs to build your own deployment tools. Let us (sol-eng@rstudio.com) know about your experience!

Overview

R users typically publish Shiny apps and other content via a push button deploy mechanism in the IDE. That mechanism calls R functions that can also be used outside the IDE in an R console. However, there are times where you may want to deploy content in RStudio Connect without using the R console. In that case you can deploy content via the RStudio Connect APIs.

Deployment Process

1. Create a content bundle

Typically, the R programmer will create the content bundle that will be deployed. The content bundle contains the application code (e.g. app.R), other files required by the application (e.g. data), and a manifest that describes the content requirements (e.g. manifest.json).

  1. Create a manifest
    > rsconnect::writeManifest()
  1. Create a content bundle
    $ tar czf bundle.tar.gz app.R data manifest.json

2. Deploy content bundle

You can use the RStudio Connect API to deploy your content programmatically. Typically IT or engineering will set up the deployment process. The deployment process might involve a number of external systems such as Git or Jenkins; however, every process at some point should connect to the following API calls. Every content bundle is deployed with a globally unique identifier (guid).

  1. Create a new content placeholder (which also generates a new guid).
    $ curl [options] POST \
    -H "Authorization: Key ${CONNECT_API_KEY}" \
    --data "${DATA}" \
    "[api]/content/"
  1. Upload the bundle to Connect
    $ curl [options] POST \
    -H "Authorization: Key ${CONNECT_API_KEY}" \
    --data-binary @"bundle.tar.gz" \
    "[api]/content/[guid]/upload"
  1. Deploy the bundle in Connect
    $ curl [options] POST \
    -H "Authorization: Key ${CONNECT_API_KEY}" \
    --data "${DATA}\
    "[api]/content/[guid]/deploy"

References

Comments